Skip to content

Commit

Permalink
ci/request-reviews: Fix for branches starting with "pr"
Browse files Browse the repository at this point in the history
Turns out if :<something> is passed, a local branch is updated, which
can conflict if the PR branch starts with "pr". I tried to avoid that
with the original code but apparently that didn't work!

https://github.com/NixOS/nixpkgs/actions/runs/11284183639/job/31384967152?pr=347822

    Fetching the PR commit history
    From https://github.com/linj-fork/nixpkgs
     * [new branch]            pr/kanata-add-version-check -> fork/pr
    error: cannot lock ref 'refs/remotes/fork/pr/kanata-add-version-check': 'refs/remotes/fork/pr' exists; cannot create 'refs/remotes/fork/pr/kanata-add-version-check'
     ! [new branch]            pr/kanata-add-version-check -> fork/pr/kanata-add-version-check  (unable to update local ref)
    error: some local refs could not be updated; try running

(cherry picked from commit 299a181)
  • Loading branch information
infinisil committed Oct 14, 2024
1 parent 01f9bc5 commit 6e6a84a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ci/request-reviews/request-reviews.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ git -C "$tmp/nixpkgs.git" remote add fork https://github.com/"$prRepo".git
git -C "$tmp/nixpkgs.git" config remote.fork.partialclonefilter tree:0
git -C "$tmp/nixpkgs.git" config remote.fork.promisor true

# This should not conflict with any refs in Nixpkgs
headRef=refs/remotes/fork/pr
# Only fetch into a remote ref, because the local ref namespace is used by Nixpkgs, don't want any conflicts
git -C "$tmp/nixpkgs.git" fetch --no-tags fork "$prBranch":"$headRef"
# Our local branches mirror Nixpkgs, so make sure to not try to update any to avoid conflicts
git -C "$tmp/nixpkgs.git" fetch --no-tags fork "$prBranch"
headRef=$(git -C "$tmp/nixpkgs.git" rev-parse HEAD)

log "Checking correctness of the base branch"
if ! "$SCRIPT_DIR"/verify-base-branch.sh "$tmp/nixpkgs.git" "$headRef" "$baseRepo" "$baseBranch" "$prRepo" "$prBranch" | tee "$tmp/invalid-base-error" >&2; then
Expand Down

0 comments on commit 6e6a84a

Please sign in to comment.