-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-files
executable file
·48 lines (40 loc) · 905 Bytes
/
git-files
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
usage() {
printf '%s\n' "Usage: git-files [-h]
git-files lists the files affected by a PR in a git repository.
where:
-h, --help - show this help text"
}
main() {
base_branch="$(gh pr status --json baseRefName --jq .currentBranch.baseRefName)"
git diff --name-only "$base_branch" \
| grep -v '^vendor/' # exclude vendor directory
}
# Option parsing
declare PARAMS=""
while (( "$#" )); do
case $1 in
-h|--help) # display help message
usage
exit 1
;;
--) # End argument parsing
shift
break
;;
-*|--*) # unsupported flags
echo "Unsupported flag: $1" >&2
usage
exit 1
;;
*) # preserve positional arguments
PARAMS="${PARAMS} $1"
shift
;;
esac
done
# set positional arguments in their proper place
eval set -- "${PARAMS}"
# Freeze configuration flags
readonly SOME_FLAG
main