-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanager.sh
More file actions
executable file
·52 lines (40 loc) · 1003 Bytes
/
manager.sh
File metadata and controls
executable file
·52 lines (40 loc) · 1003 Bytes
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
48
49
50
51
52
#!/usr/bin/env bash
set -Eeuo pipefail
declare -a \
to_be_removed
while getopts 'r:' opt; do
case "$opt" in
r) to_be_removed+=("$OPTARG") ;;
*) exit 64 ;;
esac
done
shift $((OPTIND-1))
declare -r repository="$1"
declare tmpdir
tmpdir="$(mktemp -d)"
readonly tmpdir
cd "$tmpdir"
info() {
>&2 printf '%s: %s\n' "$(date --utc +%Y-%m-%dT%H:%M:%SZ)" "$*"
}
info "Processing ${repository}"
declare remote='origin'
git clone "$repository" .
if [[ $repository =~ github.com.openshift ]]; then
info "Setting '${repository/openshift/${remote}}' as the push remote"
remote='shiftstack'
git remote add "$remote" "${repository/openshift/${remote}}"
fi
git checkout -b "shiftstack_owners"
for u in "${to_be_removed[@]}"; do
sed -i "/${u}/d" ./*OWNERS*
done
if [[ $(git status --porcelain) ]]; then
info 'Pushing the change'
git add ./*OWNERS*
git commit -m "NO-JIRA: Update ShiftStack OWNERS"
git push "$remote" shiftstack_owners --force
else
info 'No change to make'
fi
rm -rf "$tmpdir"