[PATCH] dim: Ensure a branch doesn't exist before creating it

Sean Paul seanpaul at chromium.org
Wed Jan 31 16:24:07 UTC 2018


Check the remote for the branch before creating it. Seems like this is
a noop if it does exist, aside from creating duplicate entries in the
integration config.

Signed-off-by: Sean Paul <seanpaul at chromium.org>
---
 dim | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/dim b/dim
index 73936cea4869..3639ada1854b 100755
--- a/dim
+++ b/dim
@@ -1215,6 +1215,10 @@ function dim_create_branch
 	fi
 
 	remote=$(repo_to_remote $repo)
+	if [[ $(git branch -r | grep "$remote/$branch") ]]; then
+		echoerr "$branch already exists on $remote"
+		return 1
+	fi
 
 	$DRY git branch $branch $start
 	git push $DRY_RUN $remote +$branch --set-upstream
-- 
2.16.0.rc1.238.g530d649a79-goog



More information about the dim-tools mailing list