misc: add confirmation to archive-branches script
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Mar 9, 2018 at 14:47 UTC
27b63678181c7aa570de2e917baab7181f4bf638
1 file changed
+17
-4
bin/archive-branches.sh
+17
-4
@@ -1,7 +1,6 @@
1
#!/usr/bin/env bash
2
set -euo pipefail
3
IFS=$'\n\t'
4
-set -x
4
5
auth=""
6
#auth="-u kubuxu:$GH_TOKEN"
@@ -48,9 +47,23 @@ active_branches() {
47
48
git remote add archived "git@github.com:$org/$arch_repo.git" || true
49
51
-cat <(active_branches) <(pr_branches) <((IFS=$'\n'; echo "${exclusions[*]}")) \
52
- | sort -u | comm - <(origin_refs | sort) -13 |\
53
- while read -r ref; do
50
+branches_to_move="$(cat <(active_branches) <(pr_branches) <((IFS=$'\n'; echo "${exclusions[*]}")) | sort -u | comm - <(origin_refs | sort) -13)"
51
+
52
+echo "================"
53
+printf "%s\n" "$branches_to_move"
54
+echo "================"
55
+
56
+echo "Please confirm move of above branches [y/N]:"
57
+
58
+read line
59
+case $line in
60
+ [Yy]|[Yy][Ee][Ss]) ;;
61
+ *) exit 1 ;;
62
+esac
63
+
64
+
65
+printf "%s\n" "$branches_to_move" | \
66
+while read -r ref; do
67
git push archived "origin/$ref:refs/heads/$ref/$(date --rfc-3339=date)"
68
git push origin --delete "$ref"
69
done