Skip to content

Commit 6bdf1d7

Browse files
ylabonteCopilot
andcommitted
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent f56d649 commit 6bdf1d7

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,26 @@ runs:
186186
# - `--write` without `--commit`: rewrites sit in the working tree;
187187
# diff against the index gives them.
188188
# `wf_dir%/` strips a trailing slash so the pathspec stays clean.
189+
# Git pathspecs are repo-relative, so normalize absolute workflow
190+
# directories under the repo root back to a relative path before diffing.
191+
# If an absolute path points outside the repo, fall back to the default
192+
# scoped directory instead of passing an invalid pathspec to Git.
189193
wf_dir="${GHAU_WORKFLOWS:-.github/workflows}"
190194
wf_dir="${wf_dir%/}"
195+
if git rev-parse --git-dir >/dev/null 2>&1; then
196+
top=$(git rev-parse --show-toplevel 2>/dev/null || true)
197+
if [[ "$wf_dir" = /* && -n "$top" ]]; then
198+
top="${top%/}"
199+
if [[ "$wf_dir" == "$top" ]]; then
200+
wf_dir="."
201+
elif [[ "$wf_dir" == "$top/"* ]]; then
202+
wf_dir="${wf_dir#"$top"/}"
203+
else
204+
wf_dir=".github/workflows"
205+
fi
206+
fi
207+
fi
208+
wf_dir="${wf_dir%/}"
191209
changes=0
192210
if [[ "$GHAU_WRITE" == "true" ]] && git rev-parse --git-dir >/dev/null 2>&1; then
193211
head_after=$(git rev-parse HEAD 2>/dev/null || true)

0 commit comments

Comments
 (0)