Throwaway prototypes for Sausage v3. Plan and decisions: ~/research/sausage-v3/PLAN.md. Results and evidence: the spike READMEs.
45 lines
1.8 KiB
Nu
45 lines
1.8 KiB
Nu
#!/usr/bin/env nu
|
|
# Exercise local Git operations in a fresh directory through Wasmtime.
|
|
def main [binary: path, --stubs: path] {
|
|
let binary = ($binary | path expand)
|
|
let preloads = if $stubs == null { [] } else {
|
|
glob ($stubs | path join '*.wasm') | each {|p| ['--preload' $'($p | path parse | get stem)=($p)'] } | flatten
|
|
}
|
|
let root = (^mktemp -d /tmp/s3-git/local.XXXXXX | str trim)
|
|
let repo = ($root | path join repo)
|
|
mkdir $repo
|
|
def --wrapped g [...args: string] {
|
|
print $'git ($args | str join " ")'
|
|
^wasmtime run ...$preloads --dir /tmp/s3-git/dev::/dev --dir $'($root)::/repo' --env GIT_PAGER=cat --env GIT_EDITOR=true --env GIT_AUTHOR_NAME=Spike --env GIT_AUTHOR_EMAIL=spike@example.invalid --env GIT_COMMITTER_NAME=Spike --env GIT_COMMITTER_EMAIL=spike@example.invalid --env GIT_CONFIG_NOSYSTEM=1 --env HOME=/repo -- $binary -C /repo/repo -c core.pager=cat -c maintenance.auto=false -c commit.gpgsign=false ...$args
|
|
if $env.LAST_EXIT_CODE != 0 { error make {msg: $'Git failed: ($args | str join " ")'} }
|
|
}
|
|
g init -b main
|
|
'base' | save ($repo | path join base)
|
|
g add base
|
|
g commit -m base
|
|
g status --short
|
|
g log --oneline
|
|
g branch feature
|
|
g switch feature
|
|
'feature' | save ($repo | path join feature)
|
|
g add feature
|
|
g commit -m feature
|
|
g switch main
|
|
g merge --ff-only feature
|
|
g branch side
|
|
'main' | save ($repo | path join main)
|
|
g add main
|
|
g commit -m main
|
|
g switch side
|
|
'side' | save ($repo | path join side)
|
|
g add side
|
|
g commit -m side
|
|
g switch main
|
|
g merge --no-edit side
|
|
'changed' | save --force ($repo | path join base)
|
|
g diff
|
|
g worktree add -b linked /repo/linked
|
|
if not ($root | path join linked side | path exists) { error make {msg: 'Missing worktree file'} }
|
|
print $'PASS: local operations in ($root)'
|
|
}
|