git: better use assert= than custom error + test
parent
3a23a92531
commit
aa407d1016
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2015 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: fry git io io.directories io.encodings.utf8 io.files.temp
|
||||
io.files.unique io.launcher kernel sequences tools.test ;
|
||||
USING: accessors fry git io io.directories io.encodings.utf8
|
||||
io.launcher io.streams.string kernel sequences tools.test ;
|
||||
IN: git.tests
|
||||
|
||||
: run-process-stdout ( process -- string )
|
||||
|
@ -21,6 +21,12 @@ IN: git.tests
|
|||
@
|
||||
] with-empty-test-git-repo ; inline
|
||||
|
||||
{ "hello" } [
|
||||
commit new "author" "hello\r\n"
|
||||
[ parse-commit-field ] with-string-reader
|
||||
author>>
|
||||
] unit-test
|
||||
|
||||
{ "refs/heads/master" } [
|
||||
[ git-head-ref ] with-empty-test-git-repo
|
||||
] unit-test
|
||||
|
|
|
@ -148,11 +148,6 @@ CONSTRUCTOR: <tree> tree ( -- obj ) ;
|
|||
|
||||
ERROR: unknown-commit-line line name ;
|
||||
|
||||
ERROR: string-expected got expected ;
|
||||
|
||||
: expect-string ( string expected -- )
|
||||
2dup = [ 2drop ] [ string-expected ] if ;
|
||||
|
||||
ERROR: eof-too-early ;
|
||||
ERROR: unknown-field field ;
|
||||
|
||||
|
@ -175,13 +170,11 @@ ERROR: unexpected-text text ;
|
|||
} case ;
|
||||
|
||||
: parse-commit ( bytes -- commit )
|
||||
" " split1 [ "commit" expect-string ] [ string>number read ] bi*
|
||||
" " split1 [ "commit" assert= ] [ string>number read ] bi*
|
||||
utf8 [
|
||||
commit new parse-commit-lines
|
||||
] with-byte-reader ;
|
||||
|
||||
|
||||
|
||||
: parse-tree-field ( obj parameter -- obj )
|
||||
[ "\r\n" read-until* ] dip {
|
||||
{ "tree" [ >>tree ] }
|
||||
|
@ -504,8 +497,6 @@ ERROR: repeated-parent-hash hash ;
|
|||
H{ } clone parents [
|
||||
git-head-object [
|
||||
parents>> dup string? [ random ] unless [
|
||||
! [ parents get 2dup key? [ repeated-parent-hash ] when dupd set-at ] keep
|
||||
! dup "parent: " prepend print flush yield
|
||||
dup git-unpacked-object-exists?
|
||||
[ git-read-object ] [ git-object-from-pack ] if
|
||||
] [ f ] if*
|
||||
|
|
Loading…
Reference in New Issue