-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·47 lines (38 loc) · 1.24 KB
/
release.sh
File metadata and controls
executable file
·47 lines (38 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
set -eu
cd "$(dirname "$0")"
# cargo-release wrapper for colocated jj+git repos.
#
# cargo-release drives git directly. In a colocated jj+git repo, jj's
# working-copy commit (@) sits on top of the git branch and holds any
# uncommitted changes. If @ is non-empty, or its parent is not the branch
# cargo-release expects, the release commit lands in the wrong place or trips
# cargo-release's dirty-state checks. After cargo-release moves the branch, jj
# still thinks @ is based on the old parent, which leaves stale state on the
# next jj command.
#
# This wrapper, when jj is present:
# 1. Refuses to run if @ has any changes.
# 2. Places @ as a fresh empty commit on main, so git HEAD == main.
# 3. Runs `cargo release "$@"`.
# 4. Imports the new git state into jj and re-parents @ onto the new main.
#
# When jj is absent (e.g. CI), it just execs cargo-release.
has_jj() {
command -v jj >/dev/null 2>&1 && [ -d .jj ]
}
if ! has_jj; then
exec cargo release "$@"
fi
if [ -n "$(jj diff -r @ --summary)" ]; then
echo "error: jj @ has uncommitted changes; commit or abandon before releasing" >&2
exit 1
fi
jj new main >/dev/null
set +e
cargo release "$@"
status=$?
set -e
jj git import >/dev/null
jj new main >/dev/null
exit "$status"