diff --git a/README.md b/README.md index 307c608..be3ae29 100644 --- a/README.md +++ b/README.md @@ -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 v` holds only the listed files and sits on diff --git a/scripts/pr.sh b/scripts/pr.sh index 8ae229e..ddbbe55 100755 --- a/scripts/pr.sh +++ b/scripts/pr.sh @@ -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 [] +# 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>... @@ -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 @@ -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 diff --git a/scripts/test_pr.sh b/scripts/test_pr.sh index 705ff88..938059f 100755 --- a/scripts/test_pr.sh +++ b/scripts/test_pr.sh @@ -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