Skip to content

Commit 66189cb

Browse files
Merge pull request #131 from TykTechnologies/TT-17163-fix-dependency-graph-faulure-on-branches-with-no-merge-base
TT-17163: fix dependency-guard failure on branches with no merge base
2 parents 771831a + c6bcc5e commit 66189cb

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

.github/workflows/dependency-guard.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
fetch-depth: 0
2626

2727
- name: Check for dependency changes
28-
if: ${{ !contains(github.event.pull_request.labels.*.name, inputs.label_name) }}
28+
if: ${{ github.event.pull_request && !contains(github.event.pull_request.labels.*.name, inputs.label_name) }}
2929
env:
3030
BASE_REF: ${{ github.event.pull_request.base.ref || github.event.repository.default_branch }}
3131
EXTRA_PATHS: ${{ inputs.extra_paths }}
@@ -47,7 +47,12 @@ jobs:
4747
done
4848
fi
4949
50-
CHANGED=$(git diff --name-only "origin/$BASE_REF"...HEAD -- "${PATHS[@]}")
50+
if git merge-base "origin/$BASE_REF" HEAD >/dev/null 2>&1; then
51+
CHANGED=$(git diff --name-only "origin/$BASE_REF"...HEAD -- "${PATHS[@]}")
52+
else
53+
echo "::warning title=Dependency Guard::No merge base found between HEAD and origin/$BASE_REF. Falling back to direct tree comparison (two-dot diff)."
54+
CHANGED=$(git diff --name-only "origin/$BASE_REF"..HEAD -- "${PATHS[@]}")
55+
fi
5156
5257
if [ -n "$CHANGED" ]; then
5358
echo "::error::Dependency files changed in this PR. A reviewer must verify the changes and add the '${{ inputs.label_name }}' label to unblock CI."

0 commit comments

Comments
 (0)