forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchanged-files
More file actions
executable file
·23 lines (21 loc) · 1.15 KB
/
Copy pathchanged-files
File metadata and controls
executable file
·23 lines (21 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
# Print every changed path that can affect validation, including both sides of
# renames. Disabling rename detection deliberately represents a move as a
# deletion plus an addition so a risky source cannot escape a path gate merely
# by moving out of its watched directory. Type changes are retained as well so
# replacing a watched regular file with a symlink cannot bypass validation.
set -euo pipefail
# `actions/checkout` uses a synthetic merge commit for pull-request jobs. The
# event's base SHA can lag the merge's first parent when `main` advances while
# GitHub is preparing the run; diffing that stale SHA against the merge commit
# then misclassifies unrelated base-branch changes as PR changes. The final
# review surface of a merge commit is the delta from its first parent.
if [ "$#" -eq 1 ] && [[ "$1" == *...* ]]; then
range="$1"
right_revision="${range##*...}"
if merge_parent="$(git rev-parse --verify "${right_revision}^1" 2>/dev/null)" \
&& git rev-parse --verify "${right_revision}^2" >/dev/null 2>&1; then
set -- "$merge_parent" "$right_revision"
fi
fi
exec git diff --name-only --no-renames --diff-filter=ACMRTD "$@"