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