diff --git a/justfile b/justfile index 826eabe..2823865 100644 --- a/justfile +++ b/justfile @@ -421,6 +421,9 @@ rebase-commits commit=`cd "$invokedir"; just _a_commit`: push-new-pr: #!/usr/bin/env -S bash -euo pipefail -x # TODO: verify "origin" is a nixpkgs fork and not NixOS/nixpkgs + if gum confirm --default=no "Test merging into upstream branches?"; then + just test-merge + fi declare title title="$(just _a_commit_title ||:)" title="$(gum input --placeholder="foobar: did a thing" --value="$title" ||:)" @@ -517,29 +520,39 @@ _fix +packages: pr $number=`just _a_pr`: #!/usr/bin/env -S bash -euo pipefail number=$(just _sanitize_pr_url "$number") + # TODO: support --onto + do_rebase() { + local upstream_branch="$1" # "upstream/master" + local remote="$(cut <<<"$upstream_branch" -d'/' -f1)" + local branch="$(cut <<<"$upstream_branch" -d'/' -f2)" + # TODO: gitignore ./checkout-upstream-branch.sh + printf "git checkout --autostash %q\n" "$(git rev-parse --abbrev-ref HEAD)" > checkout-upstream-branch.sh + (set -x; + $GIT checkout -b pr-"$number"-rebased-"$remote"-"$branch" ||: + $GIT pull --rebase "$remote" "$branch" || $GIT rebase --abort + ) || echo >&2 "retcode: $?" ||: + } if [[ -d prs/pr-"$number" ]]; then cd prs/pr-"$number" + if gum confirm --default=no "Force pull?"; then + upstream_branch=$( just _a_upstream_release_branch "Rebase?" "" ) + [[ ! -e ./checkout-upstream-branch.sh ]] || rm ./checkout-upstream-branch.sh + (set -x; gh pr checkout "$number" --force) + [[ -z "$upstream_branch" ]] || do_rebase "$upstream_branch" + fi elif test -d prs/pr-"$number"-*; then + # TODO: remove this backward compat cd prs/pr-"$number"-* else - # TODO: support --onto upstream_branch=$( just _a_upstream_release_branch "Rebase?" "" ) (cd master; $GIT worktree prune - (set -x; $GIT worktree add ../prs/pr-"$number") + (set -x; $GIT worktree add -b just-nixpkgs-pr-"$number"-tmp ../prs/pr-"$number") ) cd prs/pr-"$number" (set -x; gh pr checkout "$number") - if [[ -n "$upstream_branch" ]]; then - remote="$(cut <<<"$upstream_branch" -d'/' -f1)" - branch="$(cut <<<"$upstream_branch" -d'/' -f2)" - # TODO: gitignore ./checkout-upstream-branch.sh - printf "git checkout --autostash %q\n" "$(git rev-parse --abbrev-ref HEAD)" > checkout-upstream-branch.sh - (set -x; - $GIT checkout -b pr-"$number"-rebased-"$remote"-"$branch" ||: - $GIT pull --rebase "$remote" "$branch" || $GIT rebase --abort - ) || echo >&2 "retcode: $?" ||: - fi + git branch -D just-nixpkgs-pr-"$number"-tmp + [[ -z "$upstream_branch" ]] || do_rebase "$upstream_branch" fi $SHELL @@ -850,7 +863,7 @@ test-merge $rev=`cd "$invokedir"; just _a_commit` *branches: [[ -t 1 ]] || break # short circuit if only retcode matters fi done - if [[ "$retval" -eq 0]]; then + if [[ "$retval" -eq 0 ]]; then echo >&2 "No conflicts!" fi exit "$retval" @@ -880,25 +893,27 @@ open-package-urls $package=`just _a_package`: # TODO: add a recipie that allows you to determine the rootdir of the invocationdir worktree _packages_json: #!/usr/bin/env -S bash -euo pipefail - if [[ ! -s packages.json || - $(( "$epoch" - "$(stat -c %Y packages.json )" )) -gt $(( 60*60*24*7 )) - ]]; then - set -x - if ! $GIT -C master/ diff HEAD --exit-code --quiet 1>&2; then - echo >&2 "ERROR: $(realpath master) is dirty!" + echo| { # don't swallow stdin, TODO: can i do this with exec? + if [[ ! -s packages.json || + $(( "$epoch" - "$(stat -c %Y packages.json )" )) -gt $(( 60*60*24*7 )) + ]]; then + set -x + if ! $GIT -C master/ diff HEAD --exit-code --quiet 1>&2; then + echo >&2 "ERROR: $(realpath master) is dirty!" + fi + git -C master/ pull upstream master 1>&2 + time nix-env > packages.json \ + --extra-experimental-features no-url-literals \ + --option system "$(just _this_system)" \ + -f ./master \ + -qaP \ + --json \ + --meta \ + --show-trace \ + --no-allow-import-from-derivation \ + --arg config '{ allowAliases = false; }' fi - git -C master/ pull upstream master 1>&2 - time nix-env > packages.json \ - --extra-experimental-features no-url-literals \ - --option system "$(just _this_system)" \ - -f ./master \ - -qaP \ - --json \ - --meta \ - --show-trace \ - --no-allow-import-from-derivation \ - --arg config '{ allowAliases = false; }' - fi + } @_this_commit: cd "$invokedir"; $GIT log -n1 --pretty='format:%H'