2022-02-14 23:28:12 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-02-16 13:33:33 +00:00
|
|
|
set -euo pipefail
|
2022-02-14 23:28:12 +00:00
|
|
|
|
2022-07-22 00:33:15 +00:00
|
|
|
INITIAL_COMMIT="false"
|
2022-10-14 19:01:08 +00:00
|
|
|
GITHUB_OUTPUT=${GITHUB_OUTPUT:-""}
|
2023-02-16 04:42:55 +00:00
|
|
|
EXTRA_ARGS="--no-tags --prune --recurse-submodules"
|
2022-11-17 15:24:46 +00:00
|
|
|
PREVIOUS_SHA=""
|
|
|
|
CURRENT_SHA=""
|
2022-12-10 06:52:38 +00:00
|
|
|
DIFF="..."
|
2023-01-19 02:02:19 +00:00
|
|
|
IS_TAG="false"
|
2023-02-20 18:39:52 +00:00
|
|
|
SOURCE_BRANCH=""
|
2023-01-19 02:02:19 +00:00
|
|
|
|
|
|
|
if [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
|
|
|
|
IS_TAG="true"
|
2022-12-13 20:24:35 +00:00
|
|
|
EXTRA_ARGS="--prune --no-recurse-submodules"
|
2023-02-20 18:39:52 +00:00
|
|
|
SOURCE_BRANCH=${GITHUB_EVENT_BASE_REF#refs/heads/}
|
2022-11-07 06:28:15 +00:00
|
|
|
fi
|
2022-07-22 00:33:15 +00:00
|
|
|
|
2023-01-02 04:40:19 +00:00
|
|
|
if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF || "$GITHUB_EVENT_HEAD_REPO_FORK" == "true" ]]; then
|
2022-12-10 06:52:38 +00:00
|
|
|
DIFF=".."
|
|
|
|
fi
|
|
|
|
|
2022-02-14 23:28:12 +00:00
|
|
|
echo "::group::changed-files-diff-sha"
|
|
|
|
|
|
|
|
if [[ -n $INPUT_PATH ]]; then
|
|
|
|
REPO_DIR="$GITHUB_WORKSPACE/$INPUT_PATH"
|
2022-05-30 00:32:23 +00:00
|
|
|
|
2022-06-11 16:51:58 +00:00
|
|
|
echo "::debug::Resolving repository path: $REPO_DIR"
|
2022-02-14 23:28:12 +00:00
|
|
|
if [[ ! -d "$REPO_DIR" ]]; then
|
2022-06-24 04:17:41 +00:00
|
|
|
echo "::error::Invalid repository path: $REPO_DIR"
|
2022-02-14 23:28:12 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cd "$REPO_DIR"
|
|
|
|
fi
|
|
|
|
|
2022-08-21 16:44:28 +00:00
|
|
|
function __version() {
|
|
|
|
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }';
|
2022-08-13 21:50:50 +00:00
|
|
|
}
|
|
|
|
|
2022-10-31 03:03:21 +00:00
|
|
|
echo "Verifying git version..."
|
|
|
|
|
2022-09-03 00:23:52 +00:00
|
|
|
GIT_VERSION=$(git --version | awk '{print $3}') && exit_status=$? || exit_status=$?
|
2022-06-24 04:17:41 +00:00
|
|
|
|
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
|
|
|
echo "::error::git not installed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-08-13 21:50:50 +00:00
|
|
|
if [[ $(__version "$GIT_VERSION") -lt $(__version "2.18.0") ]]; then
|
2022-10-31 03:03:21 +00:00
|
|
|
echo "::error::Invalid git version. Please upgrade ($GIT_VERSION) to >= (2.18.0)"
|
2022-08-13 21:50:50 +00:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Valid git version found: ($GIT_VERSION)"
|
|
|
|
fi
|
|
|
|
|
2023-02-20 18:39:52 +00:00
|
|
|
IS_SHALLOW=$(git rev-parse --is-shallow-repository) && exit_status=$? || exit_status=$?
|
|
|
|
|
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
|
|
|
echo "::error::Unable to determine if the repository is shallow"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-01-02 04:40:19 +00:00
|
|
|
if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF ]]; then
|
2022-11-03 18:29:02 +00:00
|
|
|
echo "Running on a push event..."
|
2022-12-05 21:29:20 +00:00
|
|
|
TARGET_BRANCH=$GITHUB_REFNAME
|
2022-12-05 21:34:38 +00:00
|
|
|
CURRENT_BRANCH=$TARGET_BRANCH
|
2023-01-05 18:01:14 +00:00
|
|
|
|
2023-02-20 18:39:52 +00:00
|
|
|
if [[ "$IS_SHALLOW" == "true" ]]; then
|
2023-01-05 18:01:14 +00:00
|
|
|
echo "Fetching remote refs..."
|
2023-02-20 18:39:52 +00:00
|
|
|
if [[ "$IS_TAG" == "false" ]]; then
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$CURRENT_BRANCH":refs/remotes/origin/"$CURRENT_BRANCH" 1>/dev/null
|
|
|
|
elif [[ "$SOURCE_BRANCH" != "" ]]; then
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$SOURCE_BRANCH":refs/remotes/origin/"$SOURCE_BRANCH" 1>/dev/null
|
|
|
|
fi
|
2023-02-28 19:47:37 +00:00
|
|
|
|
|
|
|
if git submodule status &>/dev/null; then
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
git submodule foreach git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" || true
|
|
|
|
fi
|
2023-01-05 18:01:14 +00:00
|
|
|
fi
|
2022-02-14 23:28:12 +00:00
|
|
|
|
2022-11-03 18:29:02 +00:00
|
|
|
echo "::debug::Getting HEAD SHA..."
|
|
|
|
if [[ -n "$INPUT_UNTIL" ]]; then
|
|
|
|
echo "::debug::Getting HEAD SHA for '$INPUT_UNTIL'..."
|
|
|
|
CURRENT_SHA=$(git log -1 --format="%H" --date=local --until="$INPUT_UNTIL") && exit_status=$? || exit_status=$?
|
2022-10-16 00:21:02 +00:00
|
|
|
|
2022-11-03 18:29:02 +00:00
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
|
|
|
echo "::error::Invalid until date: $INPUT_UNTIL"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-10-16 00:21:02 +00:00
|
|
|
else
|
2022-11-03 18:29:02 +00:00
|
|
|
if [[ -z $INPUT_SHA ]]; then
|
2022-12-16 03:11:14 +00:00
|
|
|
CURRENT_SHA=$(git rev-list -n 1 HEAD) && exit_status=$? || exit_status=$?
|
2022-11-03 18:29:02 +00:00
|
|
|
else
|
2022-12-10 06:49:27 +00:00
|
|
|
CURRENT_SHA=$INPUT_SHA; exit_status=$?
|
2022-11-03 18:29:02 +00:00
|
|
|
fi
|
2022-10-16 00:21:02 +00:00
|
|
|
fi
|
2022-02-14 23:28:12 +00:00
|
|
|
|
2022-11-03 18:29:02 +00:00
|
|
|
echo "::debug::Verifying the current commit SHA: $CURRENT_SHA"
|
|
|
|
git rev-parse --quiet --verify "$CURRENT_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
2022-02-14 23:28:12 +00:00
|
|
|
|
2022-11-03 18:29:02 +00:00
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
|
|
|
echo "::error::Unable to locate the current sha: $CURRENT_SHA"
|
|
|
|
echo "::error::Please verify that current sha is valid, and increase the fetch_depth to a number higher than $INPUT_FETCH_DEPTH."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "::debug::Current SHA: $CURRENT_SHA"
|
|
|
|
fi
|
2022-07-18 20:34:41 +00:00
|
|
|
|
2022-02-14 23:28:12 +00:00
|
|
|
if [[ -z $INPUT_BASE_SHA ]]; then
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -n "$INPUT_SINCE" ]]; then
|
2022-10-15 22:01:59 +00:00
|
|
|
echo "::debug::Getting base SHA for '$INPUT_SINCE'..."
|
2022-10-15 23:25:37 +00:00
|
|
|
PREVIOUS_SHA=$(git log --format="%H" --date=local --since="$INPUT_SINCE" | tail -1) && exit_status=$? || exit_status=$?
|
2022-10-15 22:26:42 +00:00
|
|
|
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$PREVIOUS_SHA" ]]; then
|
|
|
|
echo "::error::Unable to locate a previous commit for the specified date: $INPUT_SINCE"
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-02-20 18:39:52 +00:00
|
|
|
elif [[ "$IS_TAG" == "true" ]]; then
|
|
|
|
PREVIOUS_SHA=$(git rev-parse "$(git tag --sort=-v:refname | head -n 2 | tail -n 1)") && exit_status=$? || exit_status=$?
|
|
|
|
|
|
|
|
if [[ -z "$PREVIOUS_SHA" ]]; then
|
|
|
|
echo "::error::Unable to locate a previous commit for the specified tag: $GITHUB_REF"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-10-14 18:59:47 +00:00
|
|
|
else
|
2022-11-07 02:50:53 +00:00
|
|
|
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then
|
|
|
|
PREVIOUS_SHA=""
|
|
|
|
|
2022-11-01 08:20:59 +00:00
|
|
|
if [[ "$GITHUB_EVENT_FORCED" == "false" || -z "$GITHUB_EVENT_FORCED" ]]; then
|
2023-01-18 23:35:50 +00:00
|
|
|
PREVIOUS_SHA=$GITHUB_EVENT_BEFORE && exit_status=$? || exit_status=$?
|
|
|
|
else
|
2023-02-09 14:33:33 +00:00
|
|
|
PREVIOUS_SHA=$(git rev-list -n 1 "HEAD^") && exit_status=$? || exit_status=$?
|
2022-11-01 08:20:59 +00:00
|
|
|
fi
|
2022-11-07 02:50:53 +00:00
|
|
|
else
|
2023-02-09 14:33:33 +00:00
|
|
|
PREVIOUS_SHA=$(git rev-list -n 1 "HEAD^") && exit_status=$? || exit_status=$?
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "0000000000000000000000000000000000000000" ]]; then
|
2023-02-09 14:33:33 +00:00
|
|
|
PREVIOUS_SHA=$(git rev-list -n 1 "HEAD^") && exit_status=$? || exit_status=$?
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2022-09-25 02:52:05 +00:00
|
|
|
|
|
|
|
if [[ "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then
|
2022-10-31 02:38:35 +00:00
|
|
|
if ! git rev-parse "$PREVIOUS_SHA^1" &>/dev/null; then
|
2022-10-14 18:59:47 +00:00
|
|
|
INITIAL_COMMIT="true"
|
2022-10-30 23:33:27 +00:00
|
|
|
PREVIOUS_SHA=$(git rev-parse "$CURRENT_SHA")
|
|
|
|
echo "::warning::Initial commit detected no previous commit found."
|
2022-10-31 03:08:40 +00:00
|
|
|
else
|
|
|
|
PREVIOUS_SHA=$(git rev-parse "$PREVIOUS_SHA^1")
|
2022-10-30 23:33:27 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [[ -z "$PREVIOUS_SHA" ]]; then
|
2022-11-24 04:46:23 +00:00
|
|
|
echo "::error::Unable to locate a previous commit."
|
2022-10-30 23:33:27 +00:00
|
|
|
exit 1
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2022-09-25 02:52:05 +00:00
|
|
|
fi
|
2022-02-26 10:09:14 +00:00
|
|
|
fi
|
2022-02-14 23:28:12 +00:00
|
|
|
else
|
2022-12-10 06:49:27 +00:00
|
|
|
PREVIOUS_SHA=$INPUT_BASE_SHA
|
2023-01-19 02:02:19 +00:00
|
|
|
|
|
|
|
if [[ "$IS_TAG" == "true" ]]; then
|
|
|
|
TARGET_BRANCH=$(git describe --tags "$PREVIOUS_SHA")
|
|
|
|
fi
|
2022-02-14 23:28:12 +00:00
|
|
|
fi
|
|
|
|
|
2022-09-25 01:08:58 +00:00
|
|
|
echo "::debug::Target branch $TARGET_BRANCH..."
|
|
|
|
echo "::debug::Current branch $CURRENT_BRANCH..."
|
|
|
|
|
2022-09-03 00:40:51 +00:00
|
|
|
echo "::debug::Verifying the previous commit SHA: $PREVIOUS_SHA"
|
2022-09-03 00:23:52 +00:00
|
|
|
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
2022-02-14 23:28:12 +00:00
|
|
|
|
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
2022-06-24 04:17:41 +00:00
|
|
|
echo "::error::Unable to locate the previous sha: $PREVIOUS_SHA"
|
2022-11-03 17:33:33 +00:00
|
|
|
echo "::error::Please verify that the previous sha commit is valid, and increase the fetch_depth to a number higher than $INPUT_FETCH_DEPTH."
|
2022-02-14 23:28:12 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
2022-09-25 01:59:18 +00:00
|
|
|
echo "Running on a pull request event..."
|
2023-01-02 04:40:19 +00:00
|
|
|
TARGET_BRANCH=$GITHUB_EVENT_PULL_REQUEST_BASE_REF
|
|
|
|
CURRENT_BRANCH=$GITHUB_EVENT_PULL_REQUEST_HEAD_REF
|
2022-11-17 19:25:27 +00:00
|
|
|
|
|
|
|
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then
|
|
|
|
TARGET_BRANCH=$CURRENT_BRANCH
|
|
|
|
fi
|
2022-02-14 23:28:12 +00:00
|
|
|
|
2023-02-20 18:39:52 +00:00
|
|
|
if [[ "$IS_SHALLOW" == "true" ]]; then
|
2023-01-05 18:01:14 +00:00
|
|
|
echo "Fetching remote refs..."
|
2023-03-10 04:01:01 +00:00
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
if git fetch $EXTRA_ARGS -u --progress origin pull/"$GITHUB_EVENT_PULL_REQUEST_NUMBER"/head:"$CURRENT_BRANCH" 1>/dev/null; then
|
|
|
|
echo "First fetch succeeded"
|
2023-03-09 03:02:52 +00:00
|
|
|
else
|
2023-03-10 04:01:01 +00:00
|
|
|
echo "First fetch failed, falling back to second fetch"
|
2023-03-09 03:02:52 +00:00
|
|
|
# shellcheck disable=SC2086
|
2023-03-10 04:01:01 +00:00
|
|
|
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$CURRENT_BRANCH"*:refs/remotes/origin/"$CURRENT_BRANCH"* 1>/dev/null || true
|
2023-03-09 03:02:52 +00:00
|
|
|
fi
|
2023-01-19 00:42:26 +00:00
|
|
|
|
|
|
|
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" != "true" ]]; then
|
|
|
|
echo "::debug::Fetching remote target branch..."
|
|
|
|
# shellcheck disable=SC2086
|
2023-02-14 04:26:59 +00:00
|
|
|
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH" 1>/dev/null
|
|
|
|
git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" 1>/dev/null || true
|
2023-01-19 00:42:26 +00:00
|
|
|
fi
|
2023-02-28 19:47:37 +00:00
|
|
|
|
|
|
|
if git submodule status &>/dev/null; then
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
git submodule foreach git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" || true
|
|
|
|
fi
|
2023-01-05 18:01:14 +00:00
|
|
|
fi
|
2022-11-07 02:50:53 +00:00
|
|
|
|
2022-11-03 18:29:02 +00:00
|
|
|
echo "::debug::Getting HEAD SHA..."
|
|
|
|
if [[ -n "$INPUT_UNTIL" ]]; then
|
|
|
|
echo "::debug::Getting HEAD SHA for '$INPUT_UNTIL'..."
|
|
|
|
CURRENT_SHA=$(git log -1 --format="%H" --date=local --until="$INPUT_UNTIL") && exit_status=$? || exit_status=$?
|
|
|
|
|
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
|
|
|
echo "::error::Invalid until date: $INPUT_UNTIL"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [[ -z $INPUT_SHA ]]; then
|
2022-12-16 03:11:14 +00:00
|
|
|
CURRENT_SHA=$(git rev-list -n 1 HEAD) && exit_status=$? || exit_status=$?
|
2022-11-03 18:29:02 +00:00
|
|
|
else
|
|
|
|
CURRENT_SHA=$INPUT_SHA; exit_status=$?
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "::debug::Verifying the current commit SHA: $CURRENT_SHA"
|
|
|
|
git rev-parse --quiet --verify "$CURRENT_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
|
|
|
|
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
|
|
|
echo "::error::Unable to locate the current sha: $CURRENT_SHA"
|
|
|
|
echo "::error::Please verify that current sha is valid, and increase the fetch_depth to a number higher than $INPUT_FETCH_DEPTH."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "::debug::Current SHA: $CURRENT_SHA"
|
2022-12-10 07:05:52 +00:00
|
|
|
fi
|
2022-11-03 18:29:02 +00:00
|
|
|
|
2022-11-03 17:47:33 +00:00
|
|
|
if [[ -z $INPUT_BASE_SHA ]]; then
|
2022-11-07 02:50:53 +00:00
|
|
|
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then
|
2022-11-08 18:06:06 +00:00
|
|
|
PREVIOUS_SHA=$GITHUB_EVENT_BEFORE
|
2022-12-19 09:06:52 +00:00
|
|
|
|
2022-12-16 19:51:54 +00:00
|
|
|
if ! git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1; then
|
2022-12-19 09:06:52 +00:00
|
|
|
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA
|
2022-12-16 19:51:54 +00:00
|
|
|
fi
|
2022-11-07 02:50:53 +00:00
|
|
|
else
|
2023-02-07 01:25:06 +00:00
|
|
|
PREVIOUS_SHA=$(git rev-parse origin/"$TARGET_BRANCH") && exit_status=$? || exit_status=$?
|
|
|
|
|
2023-02-20 18:39:52 +00:00
|
|
|
if [[ "$IS_SHALLOW" == "true" ]]; then
|
2023-02-07 01:25:06 +00:00
|
|
|
# check if the merge base is in the local history
|
2023-02-14 04:26:59 +00:00
|
|
|
if ! git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" 1>/dev/null 2>&1; then
|
2023-02-07 01:25:06 +00:00
|
|
|
echo "::debug::Merge base is not in the local history, fetching remote target branch..."
|
|
|
|
# Fetch more of the target branch history until the merge base is found
|
|
|
|
for i in {1..10}; do
|
|
|
|
# shellcheck disable=SC2086
|
2023-02-16 04:42:55 +00:00
|
|
|
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH" 1>/dev/null
|
2023-02-14 04:26:59 +00:00
|
|
|
if git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA" 1>/dev/null 2>&1; then
|
2023-02-07 01:25:06 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
echo "::debug::Merge base is not in the local history, fetching remote target branch again..."
|
|
|
|
echo "::debug::Attempt $i/10"
|
|
|
|
done
|
|
|
|
fi
|
2023-01-18 23:35:50 +00:00
|
|
|
fi
|
2022-11-07 02:50:53 +00:00
|
|
|
fi
|
|
|
|
|
2022-11-07 15:04:54 +00:00
|
|
|
if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then
|
2022-12-16 05:00:33 +00:00
|
|
|
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$?
|
2022-11-01 08:20:59 +00:00
|
|
|
fi
|
2022-11-07 15:04:54 +00:00
|
|
|
|
2022-12-05 06:54:27 +00:00
|
|
|
echo "::debug::Previous SHA: $PREVIOUS_SHA"
|
|
|
|
else
|
|
|
|
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
|
2023-01-18 23:35:50 +00:00
|
|
|
fi
|
2023-01-11 20:58:50 +00:00
|
|
|
|
2023-01-18 23:35:50 +00:00
|
|
|
if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
|
|
|
|
DIFF=".."
|
2022-11-15 16:31:41 +00:00
|
|
|
fi
|
2022-12-16 17:53:13 +00:00
|
|
|
|
2022-12-05 06:54:27 +00:00
|
|
|
echo "::debug::Target branch: $TARGET_BRANCH"
|
|
|
|
echo "::debug::Current branch: $CURRENT_BRANCH"
|
|
|
|
|
2022-09-03 00:40:51 +00:00
|
|
|
echo "::debug::Verifying the previous commit SHA: $PREVIOUS_SHA"
|
2022-09-03 00:23:52 +00:00
|
|
|
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
|
2022-02-14 23:28:12 +00:00
|
|
|
|
|
|
|
if [[ $exit_status -ne 0 ]]; then
|
2022-06-24 04:17:41 +00:00
|
|
|
echo "::error::Unable to locate the previous sha: $PREVIOUS_SHA"
|
2022-11-03 17:33:33 +00:00
|
|
|
echo "::error::Please verify that the previous sha is valid, and increase the fetch_depth to a number higher than $INPUT_FETCH_DEPTH."
|
2022-02-14 23:28:12 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2023-01-05 18:12:03 +00:00
|
|
|
|
|
|
|
if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
|
2023-01-11 20:36:35 +00:00
|
|
|
echo "::error::Unable to determine a difference between $PREVIOUS_SHA$DIFF$CURRENT_SHA"
|
2023-01-05 18:12:03 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-02-14 23:28:12 +00:00
|
|
|
fi
|
|
|
|
|
2022-11-03 12:23:50 +00:00
|
|
|
if [[ "$PREVIOUS_SHA" == "$CURRENT_SHA" && "$INITIAL_COMMIT" == "false" ]]; then
|
2022-11-03 12:50:01 +00:00
|
|
|
echo "::error::Similar commit hashes detected: previous sha: $PREVIOUS_SHA is equivalent to the current sha: $CURRENT_SHA."
|
2022-11-03 17:33:33 +00:00
|
|
|
echo "::error::Please verify that both commits are valid, and increase the fetch_depth to a number higher than $INPUT_FETCH_DEPTH."
|
2022-07-18 20:34:41 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-10-14 18:59:47 +00:00
|
|
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
|
|
|
echo "::set-output name=target_branch::$TARGET_BRANCH"
|
|
|
|
echo "::set-output name=current_branch::$CURRENT_BRANCH"
|
|
|
|
echo "::set-output name=previous_sha::$PREVIOUS_SHA"
|
|
|
|
echo "::set-output name=current_sha::$CURRENT_SHA"
|
2022-12-19 05:12:33 +00:00
|
|
|
echo "::set-output name=diff::$DIFF"
|
2022-10-14 18:59:47 +00:00
|
|
|
else
|
|
|
|
cat <<EOF >> "$GITHUB_OUTPUT"
|
2022-10-12 18:35:11 +00:00
|
|
|
target_branch=$TARGET_BRANCH
|
|
|
|
current_branch=$CURRENT_BRANCH
|
|
|
|
previous_sha=$PREVIOUS_SHA
|
|
|
|
current_sha=$CURRENT_SHA
|
2022-12-19 05:12:33 +00:00
|
|
|
diff=$DIFF
|
2022-10-12 18:35:11 +00:00
|
|
|
EOF
|
2022-10-14 18:59:47 +00:00
|
|
|
fi
|
2022-02-14 23:28:12 +00:00
|
|
|
|
|
|
|
echo "::endgroup::"
|