Skip to content

Commit

Permalink
Rebase the checkout on top of target branch
Browse files Browse the repository at this point in the history
This change will fail the action in case of rebase conflicts, but it
seems acceptable (the PR can not be merged anyway).  If needed, we may
end-up some implementing some fallback in the future.
  • Loading branch information
praiskup committed Sep 6, 2024
1 parent a7a6ed0 commit 9dca5b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ outputs:
runs:
using: docker
image: docker://quay.io/copr/vcs-diff-lint:latest
env:
INPUT_PULL_REQUEST_ID: ${{ github.event.pull_request.number }}
INPUT_PULL_REQUEST_HEAD: ${{ github.event.pull_request.head.sha }}
11 changes: 9 additions & 2 deletions container/cmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ is_true() {
}

if is_true "$INPUT_DEBUG" || is_true "$RUNNER_DEBUG"; then
( echo "== GitHub ENV VARS ==" ; env | grep ^GITHUB ) >&2
( echo "== GitHub ENV VARS ==" ; env | grep -e ^GITHUB -e ^INPUT_ ) >&2
set -x
fi

Expand Down Expand Up @@ -76,7 +76,14 @@ if test "$GITHUB_EVENT_NAME" = 'pull_request'; then
git config --global advice.detachedHead false
git config --global init.defaultBranch main

git fetch origin "$target_branch:$target_branch" &>/dev/null
(
echo "## Rebasing $INPUT_PULL_REQUEST_HEAD onto $target_branch ##"
is_true "$INPUT_DEBUG" || exec &>/dev/null
git fetch origin "$target_branch:$target_branch"
git fetch origin "+$INPUT_PULL_REQUEST_HEAD:refs/remotes/pull-requests/pr-detached-$INPUT_PULL_REQUEST_ID"
git checkout "$INPUT_PULL_REQUEST_HEAD"
git rebase "origin/$target_branch"
)

test -z "$INPUT_SUBDIRECTORY" || INPUT_SUBDIRECTORIES=$INPUT_SUBDIRECTORY
test -z "$INPUT_SUBDIRECTORIES" && INPUT_SUBDIRECTORIES=.
Expand Down

0 comments on commit 9dca5b6

Please sign in to comment.