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

chore: update test dir #872

Merged
merged 39 commits into from Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4d1ed48
chore: update test dir
jackton1 Dec 16, 2022
aabcbcc
Update diff-sha.sh
jackton1 Dec 16, 2022
bdfc50c
Update diff-sha.sh
jackton1 Dec 16, 2022
ca30b85
Update diff-sha.sh
jackton1 Dec 16, 2022
19e86cc
Update diff-sha.sh
jackton1 Dec 16, 2022
9f3cd20
Update diff-sha.sh
jackton1 Dec 16, 2022
1d0bc98
Update diff-sha.sh
jackton1 Dec 16, 2022
fd3e44b
Update test new.txt
jackton1 Dec 16, 2022
4b6b8eb
Merge branch 'main' into chore/update-test-dir
jackton1 Dec 16, 2022
4bf8a02
Update diff-sha.sh
jackton1 Dec 16, 2022
7f75cdb
Update diff-sha.sh
jackton1 Dec 16, 2022
237b051
Update diff-sha.sh
jackton1 Dec 16, 2022
0a3cc94
Update test new.txt
jackton1 Dec 16, 2022
a98e4d3
Merge branch 'main' into chore/update-test-dir
repo-ranger[bot] Dec 16, 2022
2b49b75
Update diff-sha.sh
jackton1 Dec 16, 2022
8c727be
Merge branch 'main' into chore/update-test-dir
repo-ranger[bot] Dec 16, 2022
40f3d56
Update diff-sha.sh
jackton1 Dec 16, 2022
e034ba9
Update diff-sha.sh
jackton1 Dec 16, 2022
b78225f
Merge branch 'main' into chore/update-test-dir
repo-ranger[bot] Dec 16, 2022
d4e4d24
Update diff-sha.sh
jackton1 Dec 16, 2022
d574e2b
Merge branch 'main' into chore/update-test-dir
repo-ranger[bot] Dec 16, 2022
9bb7d28
Update diff-sha.sh
jackton1 Dec 16, 2022
996300d
Update diff-sha.sh
jackton1 Dec 16, 2022
2e7b724
Update diff-sha.sh
jackton1 Dec 16, 2022
e8733f6
Update diff-sha.sh
jackton1 Dec 16, 2022
7dd5580
Update diff-sha.sh
jackton1 Dec 16, 2022
6114375
Merge branch 'main' into chore/update-test-dir
repo-ranger[bot] Dec 16, 2022
550a972
Update diff-sha.sh
jackton1 Dec 16, 2022
c1b5817
Merge branch 'main' into chore/update-test-dir
repo-ranger[bot] Dec 16, 2022
41bac1e
Update diff-sha.sh
jackton1 Dec 16, 2022
acd99f2
Update diff-sha.sh
jackton1 Dec 16, 2022
f701d66
Update diff-sha.sh
jackton1 Dec 16, 2022
e070e45
Update diff-sha.sh
jackton1 Dec 16, 2022
c3ab8f3
Update diff-sha.sh
jackton1 Dec 16, 2022
78ac3f4
Update diff-sha.sh
jackton1 Dec 16, 2022
4837447
Update diff-sha.sh
jackton1 Dec 16, 2022
6758393
Update action.yml
jackton1 Dec 16, 2022
394fc25
Merge branch 'main' into chore/update-test-dir
repo-ranger[bot] Dec 16, 2022
10aaa53
Update diff-sha.sh
jackton1 Dec 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -87,7 +87,7 @@ inputs:
max_fetch_depth:
description: "Maximum depth of the branch history fetched. **NOTE**: This can be adjusted to resolve errors with insufficient history."
required: false
default: "6000"
default: "9000"
since_last_remote_commit:
description: "Use the last commit on the remote branch as the `base_sha`. Defaults to the last non merge commit on the target branch for pull request events and the previous remote commit of the current branch for push events."
required: true
Expand Down
33 changes: 19 additions & 14 deletions diff-sha.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -euo pipefail
set -euxo pipefail

INITIAL_COMMIT="false"
GITHUB_OUTPUT=${GITHUB_OUTPUT:-""}
Expand Down Expand Up @@ -165,14 +165,14 @@ else
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress --depth=$(( GITHUB_EVENT_PULL_REQUEST_COMMITS + 1 )) origin +"$GITHUB_REF":refs/remotes/origin/"$CURRENT_BRANCH" 1>/dev/null 2>&1

COMMON_ANCESTOR=$(git rev-list --first-parent --max-parents=0 --max-count=1 origin/"$CURRENT_BRANCH") && exit_status=$? || exit_status=$?
COMMON_ANCESTOR=$(git merge-base --fork-point "$TARGET_BRANCH" HEAD) && exit_status=$? || exit_status=$?

if [[ -z "$COMMON_ANCESTOR" ]]; then
echo "::debug::Unable to locate a common ancestor for the current branch: $CURRENT_BRANCH"
else
echo "::debug::Common ancestor: $COMMON_ANCESTOR"

DATE=$(git log --date=iso8601 --format=%cd "${COMMON_ANCESTOR}")
DATE=$(git show --quiet --date=iso8601 --format=%cd "$COMMON_ANCESTOR")

if [[ -z "$DATE" ]]; then
echo "::error::Unable to locate a date for the common ancestor: $COMMON_ANCESTOR"
Expand Down Expand Up @@ -224,10 +224,14 @@ else
if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then
PREVIOUS_SHA=$GITHUB_EVENT_BEFORE
else
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA
PREVIOUS_SHA=${COMMON_ANCESTOR:-}

if [[ -z "$PREVIOUS_SHA" ]]; then
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$?
fi

if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
PREVIOUS_SHA=$(git merge-base "$PREVIOUS_SHA" "$CURRENT_SHA") && exit_status=$? || exit_status=$?
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA
fi
fi

Expand All @@ -245,11 +249,13 @@ else
depth=$INPUT_FETCH_DEPTH
max_depth=$INPUT_MAX_FETCH_DEPTH

for ((i=0; i<max_depth; i+=depth * 2)); do
for ((i=20; i<max_depth; i+=depth)); do
if git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
break
else
NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$PREVIOUS_SHA" "$CURRENT_SHA") && exit_status=$? || exit_status=$?
fi

if [[ -z "$INPUT_BASE_SHA" ]]; then
NEW_PREVIOUS_SHA=$(git merge-base --fork-point "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$?

if [[ -n "$NEW_PREVIOUS_SHA" ]]; then
PREVIOUS_SHA=$NEW_PREVIOUS_SHA
Expand All @@ -260,17 +266,16 @@ else

# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress --deepen="$i" origin $TARGET_BRANCH $CURRENT_SHA 1>/dev/null 2>&1
done

if ((i >= max_depth)); then
echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_BRANCH with: $PREVIOUS_SHA$DIFF$CURRENT_SHA"
exit 1
fi
if ((i > max_depth)); then
echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_BRANCH with: $PREVIOUS_SHA$DIFF$CURRENT_SHA"
exit 1
fi
done
else
echo "::debug::Not a shallow clone, skipping merge-base check."
fi
fi


echo "::debug::Target branch: $TARGET_BRANCH"
echo "::debug::Current branch: $CURRENT_BRANCH"
Expand Down
2 changes: 1 addition & 1 deletion test/test new.txt
@@ -1 +1 @@
This is a test file
This is a test file.