Provide world Git identity, reflog fallback, object inspection, and which (T73)
This commit is contained in:
@@ -64,6 +64,22 @@ def main [component: path, server: path = '/tmp/p1-git/server-target/debug/git-t
|
||||
{args: [log -n 1 --stat], compare: true}
|
||||
{args: [log --oneline -- file.txt], compare: true}
|
||||
{args: [show --stat], compare: true}
|
||||
{args: [show --oneline], compare: true}
|
||||
{args: [show --name-only], compare: true}
|
||||
{args: [show --oneline --stat], compare: true}
|
||||
{args: [cat-file -t HEAD], compare: true}
|
||||
{args: [cat-file -p HEAD], compare: true}
|
||||
{args: [cat-file -s HEAD], compare: true}
|
||||
{args: [cat-file -e HEAD], compare: true}
|
||||
{args: [cat-file -e absent], compare: false, exit: 128}
|
||||
{args: [cat-file -t 'HEAD:file.txt'], compare: true}
|
||||
{args: [cat-file -p 'HEAD:file.txt'], compare: true}
|
||||
{args: [cat-file -s 'HEAD:file.txt'], compare: true}
|
||||
{args: [cat-file -p 'HEAD^{tree}'], compare: true}
|
||||
{args: [ls-tree HEAD], compare: true}
|
||||
{args: [ls-tree -r HEAD], compare: true}
|
||||
{args: [ls-tree --name-only HEAD], compare: true}
|
||||
{args: [ls-tree -r --name-only HEAD file.txt], compare: true}
|
||||
{args: [rev-parse --short HEAD], compare: true}
|
||||
{args: [show HEAD], compare: true}
|
||||
{args: [show HEAD:file.txt], compare: true}
|
||||
@@ -451,6 +467,43 @@ def main [component: path, server: path = '/tmp/p1-git/server-target/debug/git-t
|
||||
if not $equal { $failures += 1; print ($expected | to json); print ($actual | to json) }
|
||||
}
|
||||
}
|
||||
# Reflog-only writes do not require the strict identity that new commits require.
|
||||
let no_identity = ($root | path join no-identity)
|
||||
mkdir $no_identity
|
||||
^git -C $no_identity init -q -b main
|
||||
'base' | save ($no_identity | path join file.txt)
|
||||
^git -C $no_identity add file.txt
|
||||
^git -C $no_identity commit --no-gpg-sign -q -m base
|
||||
mkdir ($no_identity | path join nested/sub)
|
||||
'nested' | save ($no_identity | path join nested/sub/file.txt)
|
||||
^git -C $no_identity add .
|
||||
let inspection_tree = (^git -C $no_identity write-tree | str trim)
|
||||
for args in [[ls-tree $inspection_tree] [ls-tree -r $inspection_tree] [ls-tree --name-only $inspection_tree nested] [ls-tree -r --name-only $inspection_tree nested] [ls-tree $inspection_tree nested/sub/file.txt] [cat-file -p $inspection_tree]] {
|
||||
let expected = (^git -C $no_identity ...$args | complete)
|
||||
let actual = (^wasmtime run -S http=y -S cli-exit-with-code=y --dir $'($no_identity)::/repo' $component -C /repo ...$args | complete)
|
||||
let equal = ($expected.exit_code == 0 and $actual.exit_code == 0 and $expected.stdout == $actual.stdout)
|
||||
print $'nested tree ($args): (if $equal {"PASS"} else {"FAIL"})'
|
||||
if not $equal { $failures += 1; print ($expected | to json); print ($actual | to json) }
|
||||
}
|
||||
^git -C $no_identity reset --hard -q HEAD
|
||||
^git -C $no_identity config user.useConfigOnly true
|
||||
let identity_failures = (do {
|
||||
mut failed = 0
|
||||
hide-env -i GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
|
||||
for args in [[reset --hard HEAD] [checkout -q --detach HEAD] [checkout -q main] [branch -f other HEAD] [update-ref refs/heads/other HEAD]] {
|
||||
let expected = (^git -C $no_identity ...$args | complete)
|
||||
let actual = (^wasmtime run -S http=y -S cli-exit-with-code=y --dir $'($no_identity)::/repo' $component -C /repo ...$args | complete)
|
||||
let equal = ($expected.exit_code == 0 and $actual.exit_code == 0 and $expected.stdout == $actual.stdout)
|
||||
print $'no identity ($args): (if $equal {"PASS"} else {"FAIL"})'
|
||||
if not $equal { $failed += 1; print ($expected | to json); print ($actual | to json) }
|
||||
}
|
||||
let expected = (^git -C $no_identity commit --allow-empty -m missing | complete)
|
||||
let actual = (^wasmtime run -S http=y -S cli-exit-with-code=y --dir $'($no_identity)::/repo' $component -C /repo commit --allow-empty -m missing | complete)
|
||||
if $expected.exit_code != 128 or $actual.exit_code != 128 { $failed += 1; print ($expected | to json); print ($actual | to json) }
|
||||
print 'no identity commit requires identity: checked'
|
||||
$failed
|
||||
})
|
||||
$failures += $identity_failures
|
||||
if $failures > 0 {error make {msg: $'($failures) workflow comparisons failed'}}
|
||||
}
|
||||
} catch {|err| job kill $server_job; error make {msg: $err.msg} }
|
||||
|
||||
Reference in New Issue
Block a user