gunk-dev/the-valley

valley-changes.sh

source68e9c714b9a4main's published tip history
21.4 KiB
1# shellcheck shell=bash
2# valley changes and valley pending, end to end and unmocked, over the
3# repositories one test host serves. The host is made by the integrator
4# host's rendered valley-init, relocated as init-e2e relocates it, so the
5# project list discovery reads is the one a host publishes, and every
6# record is pushed through the hook that host installs. What the
7# integrator writes on disk when it lands a change — main, the outcome
8# record, the transfer statement — is written here the same way, with a
9# key generated for the run.
10# Paths and fixtures come from the derivation environment.
11# shellcheck disable=SC2154
12set -euo pipefail
13
14w="$TMPDIR/valley-changes"
15mkdir -p "$w"
16export HOME="$w"
17export XDG_CACHE_HOME="$w/cache"
18export GIT_CONFIG_NOSYSTEM=1
19git config --global user.name valley-changes-check
20git config --global user.email valley-changes-check@localhost
21git config --global init.defaultBranch main
22git config --global advice.detachedHead false
23unset VALLEY_KNOWN_SIGNERS VALLEY_INTEGRATOR_SIGNER
24
25fail() {
26 printf 'valley-changes: %s\n' "$*" >&2
27 for f in "$w"/out "$w"/err; do
28 if [ -s "$f" ]; then cat "$f" >&2; fi
29 done
30 exit 1
31}
32
33# ok <command…>: the command succeeds, and its output is kept.
34ok() {
35 "$@" > "$w/out" 2> "$w/err" || fail "$* failed"
36}
37
38# holds <jq condition…>: the last JSON printed holds each.
39holds() {
40 local cond
41 for cond in "$@"; do
42 jq -e "$cond" "$w/out" > /dev/null || fail "$cond does not hold"
43 done
44}
45
46# line <ERE>: the last output has a line matching it.
47line() {
48 grep -qE -- "$1" "$w/out" || fail "no line matches $1"
49}
50
51no_line() {
52 if grep -qE -- "$1" "$w/out"; then fail "a line matches $1"; fi
53}
54
55# The host: guarded, open, released and sealed, with sealed the instance
56# repository. valley-init creates them, wires their hooks, and publishes
57# the project list in sealed.
58data="$w/srv/git"
59mkdir -p "$data"
60sed "s|/srv/git|$data|g" "$initScriptPath" > "$w/init.sh"
61bash "$w/init.sh" 2> "$w/init.err" || fail "valley-init failed: $(cat "$w/init.err")"
62instance="$data/sealed.git"
63# The integrator's repositories are group-shared, and git then sets the
64# setgid bit on every directory it makes, which this sandbox refuses. The
65# setting is dropped so the pushes below can write objects; it decides
66# nothing this check reads.
67for name in guarded open released sealed; do
68 git -C "$data/$name.git" config --unset core.sharedRepository || true
69done
70[ "$(git -C "$instance" cat-file blob refs/the-valley/projects)" = "$(printf '%s\n' guarded open released sealed)" ] ||
71 fail "valley-init published another project list"
72
73# A change's ID, by the letter it repeats. Each is 32 letters from k to z.
74id() { printf '%s%s' "$1" "$(printf 'k%.0s' $(seq $((32 - ${#1}))))"; }
75A="$(id nxvpwlkm)" B="$(id mmmm)" C="$(id pppp)" D="$(id qqqq)" E="$(id rrrr)"
76W="$(id ssss)" F="$(id tttt)" G="$(id uuuu)" U="$(id vvvv)" H="$(id wwww)"
77X="$(id oooo)" I="$(id zzzz)"
78R="$(id nxvpwlkz)" D2="$(id xxxx)" E2="$(id yyyy)"
79
80# A checkout of a project, whose main names sealed as its owning valley.
81# Every push carries the principal, as the key sshd authenticated would.
82export VALLEY_PRINCIPAL=klaus-env
83checkout() {
84 local name="$1" dir="$w/$1"
85 git clone --quiet "$data/$name.git" "$dir" 2> /dev/null
86 git -C "$dir" config valley.principal klaus-env
87 mkdir -p "$dir/policy"
88 printf '# the owning valley\n%s\n' "$instance" > "$dir/policy/valley"
89 git -C "$dir" add policy/valley
90 git -C "$dir" commit --quiet -m base
91 VALLEY_PRINCIPAL=integrator git -C "$dir" push --quiet origin main
92}
93
94# branch <name> <from> <subject…>: a branch from a commit, with a commit
95# per subject, each adding a file of its own, pushed to origin.
96branch() {
97 local name="$1" from="$2" s
98 shift 2
99 git checkout --quiet -b "$name" "$from"
100 for s in "$@"; do
101 echo "$s" > "$s.txt"
102 git add "$s.txt"
103 git commit --quiet -m "$s"
104 done
105 git push --quiet origin "$name"
106}
107
108# ready <id> <branch>: the branch's head readied as the change.
109ready() {
110 ok valley ready --change "$1" "$2"
111}
112
113# ----------------------------------------------------------------------
114# open: a stack of three, a draft, a withdrawn change with a ready change
115# on top of it, a change landed by fast-forward, one landed as a new
116# commit with its transfer statement, one whose request was consumed with
117# no evidence stored, one whose transfer statement another key signed,
118# and a branch no record is on.
119checkout open
120cd "$w/open"
121base="$(git rev-parse HEAD)"
122branch stack-a "$base" stack-a
123ready "$A" stack-a
124branch stack-b stack-a stack-b
125ready "$B" stack-b
126branch stack-c stack-b stack-c
127ready "$C" stack-c
128branch paused "$base" paused
129ready "$D" paused
130ok valley unready "$D"
131branch gone "$base" gone
132ready "$E" gone
133ok valley withdraw "$E"
134branch atop-gone gone atop-gone
135ready "$W" atop-gone
136branch ff "$base" ff
137ready "$F" ff
138branch reparent "$base" reparent
139ready "$G" reparent
140branch lost "$base" lost
141ready "$U" lost
142branch forged "$base" forged
143ready "$H" forged
144branch loose "$base" loose
145
146# Before anything lands, ff names its change.
147ok valley-go resolve ff
148line "^change"$'\t'"$F"$'\t'
149
150# The integrator's keys: the integrator's own, and another a known
151# signer holds, which may sign evidence and not a landing.
152ssh-keygen -q -t ed25519 -N '' -C integrator -f "$w/integrator.key"
153ssh-keygen -q -t ed25519 -N '' -C mallory -f "$w/mallory.key"
154{
155 attest key --key "$w/integrator.key" --name integrator
156 attest key --key "$w/mallory.key" --name mallory
157} > "$w/known-signers"
158
159# F lands by fast-forward.
160VALLEY_PRINCIPAL=integrator git push --quiet origin ff:main
161fhead="$(git rev-parse ff)"
162
163# G lands as a new commit on main, and the integrator records it: main
164# moves, the outcome record says land, the request is consumed, and the
165# transfer statement is stored under the landed tree.
166git checkout --quiet -b landing ff
167git cherry-pick reparent > /dev/null
168landed="$(git rev-parse HEAD)"
169VALLEY_PRINCIPAL=integrator git push --quiet origin landing:main
170tree_digest() { attest digest --repo "$w/open" --rev "$1" | cut -d: -f2; }
171
172# memo <name> <head> <decision…>: the integrator's outcome record.
173memo() {
174 local name="$1" head="$2" blob
175 shift 2
176 blob="$(printf '%s %s %s %s\n' "$head" "$fhead" 0123456789abcdef "$*" | git -C "$data/open.git" hash-object -w --stdin)"
177 git -C "$data/open.git" update-ref "refs/the-valley/integration-outcomes/main/$name" "$blob"
178}
179
180# transfer <change> <head> <landed> <key> <name>: a transfer statement,
181# as the integrator composes, signs and stores one.
182transfer() {
183 local change="$1" head="$2" at="$3" key="$4" name="$5" ldigest blob tree
184 ldigest="$(tree_digest "$at")"
185 jq -n --arg change "$change" --arg base "$(tree_digest "$head")" --arg landed "$ldigest" \
186 --arg commit "$at" --arg tip "$fhead" '{
187 statementType: "the-valley/attestation/v1",
188 subject: {primary: "valley-tree-v1", digest: {"valley-tree-v1": $landed, "git-sha1": $commit}},
189 predicateType: "the-valley/integration/transfer/v1",
190 predicate: {change: $change, target: "refs/heads/main", base: {"valley-tree-v1": $base},
191 policy: {sha256: ("ab" * 32), "git-sha1": $tip}, required: "none"}
192 }' > "$w/statement.json"
193 attest render "$w/statement.json" | attest sign --key "$key" --name "$name" > "$w/transfer.note"
194 blob="$(git -C "$data/open.git" hash-object -w "$w/transfer.note")"
195 tree="$(printf '100644 blob %s\ttransfer.note\n' "$blob" | git -C "$data/open.git" mktree)"
196 git -C "$data/open.git" update-ref "refs/the-valley/attestations/$ldigest/$(printf '%08x' "${#name}")" "$tree"
197}
198memo reparent "$(git rev-parse reparent)" land
199transfer reparent "$(git rev-parse reparent)" "$landed" "$w/integrator.key" integrator
200
201# U's request was consumed, and no evidence was stored.
202memo lost "$(git rev-parse lost)" land
203# H's request was consumed too, and its transfer statement is signed by a
204# known key that is not the integrator's: it is no record of a landing.
205memo forged "$(git rev-parse forged)" land
206git checkout --quiet -b landing-h landing
207git cherry-pick forged > /dev/null
208VALLEY_PRINCIPAL=integrator git push --quiet origin landing-h:main
209transfer forged "$(git rev-parse forged)" "$(git rev-parse HEAD)" "$w/mallory.key" mallory
210# A's request is pending.
211git -C "$data/open.git" update-ref refs/the-valley/integration-requests/main/stack-a "$(git rev-parse stack-a)"
212
213# X is ready, and a merge of it whose tree drops its changes lands on main
214# by fast-forward. main reaches X only through the merge's second parent,
215# which is no landing.
216branch dropped "$base" dropped
217ready "$X" dropped
218git checkout --quiet landing-h
219merge="$(git commit-tree "landing-h^{tree}" -p landing-h -p dropped -m 'merge, dropping X')"
220VALLEY_PRINCIPAL=integrator git push --quiet origin "$merge:refs/heads/main"
221
222# I lands as a new commit, L2, filed as c-<I>, and the integrator records
223# it. Then I's next version, H', has H's tree with L2 as its parent. Its
224# name and its tree digest match the transfer statement, but it is another
225# delta: merged onto L2's parent it does not give L2's tree. I is then made
226# a draft.
227branch again "$base" again
228ready "$I" again
229hhead="$(git rev-parse again)"
230git checkout --quiet -b landing-i "$merge"
231git cherry-pick again > /dev/null
232landed2="$(git rev-parse HEAD)"
233VALLEY_PRINCIPAL=integrator git push --quiet origin landing-i:main
234memo "c-$I" "$hhead" land
235transfer "c-$I" "$hhead" "$landed2" "$w/integrator.key" integrator
236hprime="$(git commit-tree "again^{tree}" -p "$landed2" -m again)"
237git push --quiet --force origin "$hprime:refs/heads/again"
238ready "$I" again
239ok valley unready "$I"
240
241# ----------------------------------------------------------------------
242# guarded: a ready change whose ID shares seven letters with A's, a draft
243# and a withdrawn change.
244checkout guarded
245cd "$w/guarded"
246gbase="$(git rev-parse HEAD)"
247branch g-ready "$gbase" g-ready
248ready "$R" g-ready
249branch g-draft "$gbase" g-draft
250ready "$D2" g-draft
251ok valley unready "$D2"
252branch g-gone "$gbase" g-gone
253ready "$E2" g-gone
254ok valley withdraw "$E2"
255# B's change ID, recorded here too.
256branch g-dup "$gbase" g-dup
257ready "$B" g-dup
258
259# released is listed and cannot be read.
260mv "$data/released.git" "$data/released.moved"
261
262export VALLEY_KNOWN_SIGNERS="$w/known-signers" VALLEY_INTEGRATOR_SIGNER=integrator
263
264# ----------------------------------------------------------------------
265# One repository: every record in every state, as valley-changes/v1.
266cd "$w/open"
267ok valley changes --json
268[ "$(wc -l < "$w/out")" = 1 ] || fail "changes printed more than one line"
269holds '.schema == "valley-changes/v1"' '.host == "localhost"' '(.repos | length) == 1' \
270 '.repos[0].repo == "open"' ".repos[0].url == \"$data/open.git\"" '.repos[0].error == null' \
271 '(.repos[0].changes | length) == 12' '.repos[0] | has("drafts") | not'
272c() { printf '.repos[0].changes[] | select(.change_id == "%s")' "$1"; }
273holds "$(c "$A") | .handle == \"nxvp\" and .state == \"ready\" and .owner == \"klaus-env\" and .target == \"main\" and .active == 1 and .seq == 1" \
274 "$(c "$A") | .record == \"$(git -C "$data/open.git" rev-parse "refs/the-valley/changes/main/$A")\"" \
275 "$(c "$A") | .versions[0] | .n == 1 and .title == \"stack-a\" and .branch == \"stack-a\" and .uploader == \"klaus-env\"" \
276 "$(c "$A") | .versions[0] | .head == \"$(git rev-parse stack-a)\" and .landing == \"not-landed\" and .landed_commit == null" \
277 "$(c "$A") | .versions[0].request == {ref: \"refs/the-valley/integration-requests/main/stack-a\", commit: \"$(git rev-parse stack-a)\"}" \
278 "$(c "$A") | .versions[0].outcome == null" \
279 "$(c "$D") | .state == \"draft\" and .seq == 2" \
280 "$(c "$E") | .state == \"withdrawn\""
281# Landing evidence, one version each way.
282holds "$(c "$F") | .versions[0] | .landing == \"landed\" and .landed_commit == \"$fhead\"" \
283 "$(c "$G") | .versions[0] | .landing == \"landed-recorded\" and .landed_commit == \"$landed\"" \
284 "$(c "$G") | .versions[0].outcome == {decision: \"land\", head: \"$(git rev-parse reparent)\", tip: \"$fhead\"}" \
285 "$(c "$G") | .versions[0].request == null" \
286 "$(c "$U") | .versions[0] | .landing == \"uncertain\" and .landed_commit == null" \
287 "$(c "$H") | .versions[0].landing == \"uncertain\"" \
288 "$(c "$X") | .versions[0] | .landing == \"not-landed\" and .landed_commit == null" \
289 "$(c "$I") | .versions[0] | .landing == \"landed-recorded\" and .landed_commit == \"$landed2\"" \
290 "$(c "$I") | .versions[1] | .head == \"$hprime\" and .landing == \"not-landed\" and .landed_commit == null" \
291 "$(c "$I") | .state == \"draft\" and .active == 2"
292# includes is ancestry, nearest only.
293holds "$(c "$A") | .includes == []" "$(c "$B") | .includes == [\"$A\"]" \
294 "$(c "$C") | .includes == [\"$B\"]" "$(c "$W") | .includes == [\"$E\"]"
295# The one branch no record is on, and no branch main reaches.
296holds '.repos[0].branches == [{branch: "loose", head: "'"$(git rev-parse loose)"'"}]'
297
298# Without the registry's keys, the transfer statement is not believed, and
299# that is said.
300env -u VALLEY_KNOWN_SIGNERS valley changes --json > "$w/out" 2> "$w/err" || fail "changes failed without the keys"
301holds "$(c "$G") | .versions[0].landing == \"uncertain\""
302grep -q 'could not be verified' "$w/err" || fail "an unverified transfer statement was not reported"
303
304# ----------------------------------------------------------------------
305# Every project the host publishes. Handles are unique across both
306# repositories, the repository that cannot be read carries its error, and
307# the others are listed all the same.
308ok valley changes --json --all
309holds '[.repos[].repo] == ["guarded", "open", "released", "sealed"]' \
310 '.repos[] | select(.repo == "released") | .error != null and .changes == [] and .url == "'"$data/released.git"'"' \
311 '.repos[] | select(.repo != "released") | .error == null' \
312 '.repos[] | select(.repo == "sealed") | .changes == []' \
313 '[.repos[].changes[].handle] | length == (unique | length)' \
314 "[.repos[].changes[] | select(.change_id == \"$A\" or .change_id == \"$R\") | .handle] == [\"nxvpwlkz\", \"nxvpwlkm\"]" \
315 "[.repos[].changes[] | select(.change_id == \"$B\") | .handle] == [\"guarded/mmmm\", \"open/mmmm\"]" \
316 '.repos[] | select(.repo == "guarded") | [.changes[].state] == ["ready", "ready", "draft", "withdrawn"]'
317# ls-remote matches a ref's tail, so refs whose names end like the
318# refs discovery reads must not stand in for them: one in open whose
319# policy/valley names another instance, and one in the instance listing
320# another project.
321git checkout --quiet -b decoy "$base"
322printf '%s\n' "$w/elsewhere.git" > policy/valley
323git commit --quiet -am decoy
324git push --quiet origin decoy:refs/heads/a/refs/heads/main
325decoy_list="$(printf 'decoy\n' | git -C "$instance" hash-object -w --stdin)"
326git -C "$instance" update-ref refs/tags/a/refs/the-valley/projects "$decoy_list"
327git checkout --quiet landing
328ok valley changes --json --all
329holds '[.repos[].repo] == ["guarded", "open", "released", "sealed"]'
330git push --quiet origin :refs/heads/a/refs/heads/main
331git -C "$instance" update-ref -d refs/tags/a/refs/the-valley/projects
332# --repo limits the listing to one repository, read through its clone.
333ok valley changes --json --repo guarded
334holds '[.repos[].repo] == ["guarded"]' "[.repos[0].changes[].change_id] == [\"$B\", \"$R\", \"$D2\", \"$E2\"]" \
335 '[.repos[0].changes[].handle] == ["mmmm", "nxvp", "xxxx", "yyyy"]'
336cd "$w/guarded"
337ok valley changes --json
338holds '[.repos[].repo] == ["guarded"]' '[.repos[0].changes[].handle] == ["mmmm", "nxvp", "xxxx", "yyyy"]'
339# A qualified handle names the change in the repository it qualifies.
340ok valley-go resolve guarded/mmmm
341line "^change"$'\t'"$B"$'\t'"mmmm"$'\t'"1"$'\t'"$(git rev-parse g-dup)"$'\t'
342cd "$w/open"
343ok valley-go resolve open/mmmm
344line "^change"$'\t'"$B"$'\t'"mmmm"$'\t'"1"$'\t'"$(git rev-parse stack-b)"$'\t'
345cd "$w/guarded"
346if valley changes --json --repo nowhere > "$w/out" 2> "$w/err"; then fail "--repo took a project the host does not list"; fi
347grep -q 'lists no project nowhere' "$w/err" || fail "--repo nowhere was refused without saying why"
348cd "$w/open"
349
350# A repository whose main names no owning valley lists itself alone, and
351# says discovery is unavailable.
352git init --quiet --bare "$w/solo.git"
353git clone --quiet "$w/solo.git" "$w/solo" 2> /dev/null
354git -C "$w/solo" commit --quiet --allow-empty -m solo
355git -C "$w/solo" push --quiet origin main
356(cd "$w/solo" && valley changes --json --all) > "$w/out" 2> "$w/err" || fail "changes --all failed without discovery"
357holds '[.repos[].repo] == ["solo"]'
358grep -q 'discovery is unavailable' "$w/err" || fail "changes --all did not say discovery is unavailable"
359
360# A policy/valley that git would read as an option, or that names a remote
361# helper, is refused before git sees it, and nothing it names runs, even
362# where the caller's own configuration allows ext::.
363for url in "--upload-pack=touch $w/pwned; git-upload-pack" "ext::sh -c touch% $w/pwned"; do
364 rm -rf "$w/evil.git" "$w/evil"
365 git init --quiet --bare "$w/evil.git"
366 git clone --quiet "$w/evil.git" "$w/evil" 2> /dev/null
367 mkdir -p "$w/evil/policy"
368 printf '%s\n' "$url" > "$w/evil/policy/valley"
369 git -C "$w/evil" add policy
370 git -C "$w/evil" commit --quiet -m evil
371 git -C "$w/evil" push --quiet origin main
372 export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=protocol.ext.allow GIT_CONFIG_VALUE_0=always
373 (cd "$w/evil" && valley changes --json --all) > "$w/out" 2> "$w/err" || fail "changes --all failed over policy/valley $url"
374 holds '[.repos[].repo] == ["evil"]'
375 grep -q 'discovery is unavailable' "$w/err" || fail "policy/valley $url was not refused"
376 if (cd "$w/evil" && valley changes --json --repo other) > "$w/out" 2> "$w/err"; then
377 fail "--repo read through policy/valley $url"
378 fi
379 unset GIT_CONFIG_COUNT GIT_CONFIG_KEY_0 GIT_CONFIG_VALUE_0
380 [ ! -e "$w/pwned" ] || fail "policy/valley $url ran a command"
381done
382
383# ----------------------------------------------------------------------
384# pending: the ready changes that have not landed, by handle, version and
385# title, then the branches no record is on, then the drafts.
386ok valley pending
387line '^nxvp v1 \| stack-a$'
388line '^mmmm v1 \| stack-b \| includes nxvp$'
389line '^pppp v1 \| stack-c \| includes mmmm$'
390line '^ssss v1 \| atop-gone \| includes rrrr$'
391line '^vvvv v1 \| lost \| uncertain$'
392line '^wwww v1 \| forged \| uncertain$'
393line '^oooo v1 \| dropped$'
394no_line '^(tttt|uuuu|rrrr|qqqq) v1 \|'
395line '^branches$'
396line '^loose \| loose \| .* \| ahead 1 \| 1 file changed'
397line '^drafts$'
398line '^qqqq v1 on paused \| paused \| .* \| ahead 1 \| '
399line '^zzzz v2 on again \| again \| '
400[ "$(grep -n '^branches$' "$w/out" | cut -d: -f1)" -lt "$(grep -n '^drafts$' "$w/out" | cut -d: -f1)" ] ||
401 fail "pending listed the drafts before the branches"
402# --json is the same listing in valley-changes/v1's shape: the pending
403# changes alone in changes, and the drafts in drafts.
404ok valley pending --json
405holds '.schema == "valley-pending/v1"' \
406 '[.repos[0].changes[].handle] == ["mmmm", "nxvp", "oooo", "pppp", "ssss", "vvvv", "wwww"]' \
407 '[.repos[0].changes[].state] | unique == ["ready"]' \
408 '[.repos[0].drafts[] | [.handle, .state]] == [["qqqq", "draft"], ["zzzz", "draft"]]' \
409 '.repos[0].branches == [{branch: "loose", head: "'"$(git rev-parse loose)"'"}]'
410# Across the host, each repository is headed by its name.
411ok valley pending --all
412line '^guarded$'
413line '^nxvpwlkz v1 \| g-ready$'
414line '^guarded drafts$'
415line '^open$'
416line '^nxvpwlkm v1 \| stack-a$'
417line '^open/mmmm v1 \| stack-b \| includes nxvpwlkm$'
418line '^pppp v1 \| stack-c \| includes open/mmmm$'
419line '^guarded/mmmm v1 \| g-dup$'
420line '^released: could not read '
421
422# --owes ends each change's line with the checks it owes, by cost, as
423# valley checks derives them, here and in a repository read through its
424# clone. The instance gets a floor for that, written to its main on disk
425# as the integrator would.
426git init --quiet "$w/floor"
427mkdir -p "$w/floor/policy/instance"
428cp "$floor"/*.cue "$w/floor/policy/instance/"
429git -C "$w/floor" add policy
430git -C "$w/floor" commit --quiet -m floor
431git -C "$w/floor" push --quiet "$instance" HEAD:refs/heads/floor
432git -C "$instance" update-ref refs/heads/main "$(git -C "$w/floor" rev-parse HEAD)"
433ok valley pending --owes --all
434line '^nxvpwlkm v1 \| stack-a \| owes 1 quick, 0 slow$'
435line '^open/mmmm v1 \| stack-b \| includes nxvpwlkm \| owes 1 quick, 0 slow$'
436line '^nxvpwlkz v1 \| g-ready \| owes 1 quick, 0 slow$'
437
438# ----------------------------------------------------------------------
439# A branch name is used again once its change has landed: ff now names no
440# change, and reparent none either, once its transfer statement verifies.
441ok valley-go resolve ff
442line "^branch"$'\t'"ff$"
443ok valley-go resolve reparent
444line "^branch"$'\t'"reparent$"
445env -u VALLEY_KNOWN_SIGNERS valley-go resolve reparent > "$w/out" 2> "$w/err" || fail "resolve failed"
446line "^change"$'\t'"$G"$'\t'
447ok valley-go resolve stack-a
448line "^change"$'\t'"$A"$'\t'
449
450# H' has not landed, so its branch still names I, which is a draft, and
451# approving the branch is refused for I's state rather than taken as a
452# plain branch.
453ok valley-go resolve again
454line "^change"$'\t'"$I"$'\t'"zzzz"$'\t'"2"$'\t'"$hprime"$'\t'"again"$'\t'"draft$"
455if valley approve again > "$w/out" 2> "$w/err"; then fail "approve took the branch of a draft"; fi
456grep -q "change zzzz v2 is draft, not ready" "$w/err" || fail "approve did not refuse the draft for its state"
457
458# A landed change stops naming its branch only while the branch is still
459# at the landed head. Once ff moves, it names F again.
460git checkout --quiet -b ff-again ff
461echo more > more.txt
462git add more.txt
463git commit --quiet -m more
464git push --quiet origin ff-again:ff
465ok valley-go resolve ff
466line "^change"$'\t'"$F"$'\t'
467
468# valley help names the verbs klaus looks for.
469valley help > "$w/out"
470line '^ ready '
471line '^ changes '
472
473touch "$out"