Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase the checkout on top of target branch #32

Merged
merged 1 commit into from
Sep 6, 2024
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
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