Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ the files a bump changes, and writes the version in `_write-version`; copy

- `just merge [TITLE]`: pushes the current feature branch (also when origin
does not have it yet), opens the pull request and turns on auto-merge. It
refuses a changed version and a title starting with `release `.
refuses a changed version and a title starting with `release `. A
repository without a version, whose `main` is the publication (a content
site, a plugin marketplace), passes `-` as version file and has no release
recipes.
- `just release-patch`: the next version is computed from the version on
`origin/main`, so a second run on the same branch does not bump twice. The
release commit `release <name> v<x>` holds only the listed files and sits on
Expand Down
17 changes: 10 additions & 7 deletions scripts/pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
# script at IronFlock/workflows@v1 and runs it, so the flow is the same
# everywhere (see "Pull requests from a laptop" in the README).
#
# pr.sh merge <version-file> [<title>]
# pr.sh merge <version-file|-> [<title>]
# a no-release pull request from the current feature branch (pushed even
# if origin does not have it yet), titled <title> (default: the subject
# of the branch's first commit), merged automatically (squash) once the
# required checks pass. The version must equal main's, and the title must
# required checks pass. The version must equal main's (`-`: a repository
# without a version, whose main is the publication), and the title must
# not start with "release ": such a merge releases nothing.
#
# pr.sh release <patch|minor|major> <name> <version-file> <workflow> <file>...
Expand Down Expand Up @@ -100,7 +101,7 @@ leave_branch() {
}

cmd_merge() {
[ $# -ge 1 ] || die "usage: pr.sh merge <version-file> [<title>]"
[ $# -ge 1 ] || die "usage: pr.sh merge <version-file|-> [<title>]"
local vf=$1 title=${2:-} branch here there
branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$branch" = main ] || [ "$branch" = HEAD ]; then
Expand All @@ -110,10 +111,12 @@ cmd_merge() {
git fetch --quiet origin main
git merge-base --is-ancestor origin/main HEAD ||
die "merge: $branch does not contain origin/main (git rebase origin/main)"
here=$(version "$vf")
there=$(version "$vf" origin/main)
[ "$here" = "$there" ] ||
die "merge: $branch changes the version ($there -> $here): that is a release (just release-patch)"
if [ "$vf" != - ]; then
here=$(version "$vf")
there=$(version "$vf" origin/main)
[ "$here" = "$there" ] ||
die "merge: $branch changes the version ($there -> $here): that is a release (just release-patch)"
fi
[ -n "$title" ] || title=$(git log --reverse --format=%s origin/main..HEAD | head -n1)
[ -n "$title" ] || die "merge: no commits on $branch beyond main"
if release_title "$title"; then
Expand Down
7 changes: 7 additions & 0 deletions scripts/test_pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ expect "merge: squash auto-merge" logged "gh pr merge feat --squash --auto --del
check "merge: an existing pull request is reused" 0 merge VERSION "docs: another title"
expect "merge: no second pull request" not_logged "gh pr create"

setup VERSION 1.2.3
git -C "$repo" rm -q VERSION
git -C "$repo" commit -q -m "a repository without a version"
# stdin holds a version: read as a file name, '-' would compare it with main's.
check "merge: '-' for a repository without a version file" 0 merge - <<<"9.9.9"
expect "merge: '-' still opens the pull request" logged "gh pr create --base main --head feat"

setup VERSION 1.2.3
git -C "$repo" switch -q main
check "merge: refused on main" 1 merge VERSION
Expand Down
Loading