File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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)
You can’t perform that action at this time.
0 commit comments