mirror of
https://github.com/tj-actions/changed-files
synced 2024-12-16 19:27:39 +00:00
Updated to use the last remote commit by default.
This commit is contained in:
parent
2c4c729f2a
commit
5485a02af8
2 changed files with 10 additions and 15 deletions
|
@ -189,6 +189,7 @@ runs:
|
|||
GITHUB_HEAD_REF: ${{ github.head_ref }}
|
||||
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||
GITHUB_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
|
||||
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
|
||||
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
|
||||
INPUT_SHA: ${{ steps.sha.outputs.sha }}
|
||||
|
|
24
diff-sha.sh
24
diff-sha.sh
|
@ -57,30 +57,24 @@ else
|
|||
fi
|
||||
|
||||
if [[ -z $GITHUB_BASE_REF ]]; then
|
||||
TARGET_BRANCH=${GITHUB_REF/refs\/heads\//}
|
||||
CURRENT_BRANCH=$TARGET_BRANCH
|
||||
|
||||
echo "::debug::GITHUB_BASE_REF unset using $TARGET_BRANCH..."
|
||||
TARGET_BRANCH=${GITHUB_REF/refs\/heads\//} && exit_status=$? || exit_status=$?
|
||||
CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$?
|
||||
|
||||
if [[ -z $INPUT_BASE_SHA ]]; then
|
||||
git fetch --no-tags -u --progress origin --depth=2 "${TARGET_BRANCH}":"${TARGET_BRANCH}" && exit_status=$? || exit_status=$?
|
||||
|
||||
if [[ $(git rev-list --count "HEAD") -gt 1 ]]; then
|
||||
PREVIOUS_SHA=$(git rev-parse "@~1" 2>&1) && exit_status=$? || exit_status=$?
|
||||
echo "::debug::Previous SHA: $PREVIOUS_SHA"
|
||||
else
|
||||
PREVIOUS_SHA=$CURRENT_SHA; exit_status=$?
|
||||
PREVIOUS_SHA=$GITHUB_EVENT_BEFORE
|
||||
if [[ "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then
|
||||
INITIAL_COMMIT="true"
|
||||
echo "::debug::Initial commit detected"
|
||||
echo "::debug::Previous SHA: $PREVIOUS_SHA"
|
||||
fi
|
||||
else
|
||||
PREVIOUS_SHA=$INPUT_BASE_SHA; exit_status=$?
|
||||
PREVIOUS_SHA=$INPUT_BASE_SHA
|
||||
TARGET_BRANCH=$(git name-rev --name-only "$PREVIOUS_SHA" 2>&1) && exit_status=$? || exit_status=$?
|
||||
echo "::debug::Previous SHA: $PREVIOUS_SHA"
|
||||
echo "::debug::Target branch: $TARGET_BRANCH"
|
||||
CURRENT_BRANCH=$TARGET_BRANCH
|
||||
fi
|
||||
|
||||
echo "::debug::Target branch $TARGET_BRANCH..."
|
||||
echo "::debug::Current branch $CURRENT_BRANCH..."
|
||||
|
||||
echo "::debug::Verifying the previous commit SHA: $PREVIOUS_SHA"
|
||||
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
||||
|
||||
|
|
Loading…
Reference in a new issue