safe-abandon: Add in a new command to prevent ultimate sadness
The "repo abandon" command has a really bad habit of reverting changes across
the entire set of projects it's assigned to manage if you forget to specify a
project. Sadly, "repo start" used to be symmetrical, but now only affects the
current project.
This adds a "safe-abandon" command to our build setup so that we have an option
to prevent the ultimate sadness that occurs when you accidentally forget to
specify which project to abandon a branch in.
You're welcome. :(
Change-Id: I29519ffd1c315d492ebdc555a77712bfa31c596a
diff --git a/setup.sh b/setup.sh
index 8dcc2c3..ef265cf 100755
--- a/setup.sh
+++ b/setup.sh
@@ -90,6 +90,24 @@
popd >/dev/null
}
+function safe-abandon
+{
+ local branch="${1}"; shift
+
+ if [[ -z "${branch}" ]]; then
+ echo "Usage: safe-abandon <branchname>"
+ echo
+ echo "Abandons a repo branch in the current project only."
+ echo "This is much safer than using the actual 'repo abandon'"
+ echo "command, since it won't globally revert branches across"
+ echo "the entire project space."
+ echo
+ return 1
+ fi
+
+ repo abandon "${branch}" .
+}
+
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
unset JUMP_TARGETS
declare -Ax JUMP_TARGETS