Skip to content

Commit

Permalink
disable diff support for shallow git checkouts
Browse files Browse the repository at this point in the history
  • Loading branch information
radhermit committed Nov 29, 2024
1 parent 2f33a4a commit 6f85f3b
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions pkgcruft-action
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ set +e

# run scanning in a subshell with `set -e` enabled
(
# determine old commit for diff targeting
if [[ -n ${GIT_BASE_BRANCH} ]]; then
# pull request
OLD_COMMIT=$(git rev-parse origin/${GIT_BASE_BRANCH})
OLD_COMMIT_NAME=origin/${GIT_BASE_BRANCH}
elif [[ ${GIT_BRANCH} != ${GIT_DEFAULT_BRANCH} ]]; then
# non-default branch
OLD_COMMIT=$(git rev-parse origin/${GIT_DEFAULT_BRANCH})
OLD_COMMIT_NAME=origin/${GIT_DEFAULT_BRANCH}
else
OLD_COMMIT=$(git rev-parse HEAD~1)
OLD_COMMIT_NAME=$(git rev-parse --short HEAD~1)
fi

# disable diff support if the target commits don't exist due a shallow git checkout
DIFF_SUPPORT=$?

set -e

# TODO: replace with native pkgcraft repo syncing functionality
Expand Down Expand Up @@ -41,18 +58,9 @@ set +e
echo Current pkgcruft results: ${NEW_COMMIT_NAME}
pkgcruft replay --color --sort "${FILE}"

# determine old commit for diff targeting
if [[ -n ${GIT_BASE_BRANCH} ]]; then
# pull request
OLD_COMMIT=$(git rev-parse origin/${GIT_BASE_BRANCH})
OLD_COMMIT_NAME=origin/${GIT_BASE_BRANCH}
elif [[ ${GIT_BRANCH} != ${GIT_DEFAULT_BRANCH} ]]; then
# non-default branch
OLD_COMMIT=$(git rev-parse origin/${GIT_DEFAULT_BRANCH})
OLD_COMMIT_NAME=origin/${GIT_DEFAULT_BRANCH}
else
OLD_COMMIT=$(git rev-parse HEAD~1)
OLD_COMMIT_NAME=$(git rev-parse --short HEAD~1)
if [[ ${DIFF_SUPPORT} != 0 ]]; then
echo Skipping pkgcruft diff: running in shallow git checkout
exit 0
fi

# Generate results for old commit if they don't exist
Expand Down

0 comments on commit 6f85f3b

Please sign in to comment.