From 9fac8eedc2f0e90528de39557b6ebe99a380cf4a Mon Sep 17 00:00:00 2001 From: Marcus Lagergren <1062473+lagergren@users.noreply.github.com> Date: Sun, 15 Sep 2024 21:35:59 +0200 Subject: [PATCH] Modded scripts --- bin/git-delete-branch.sh | 21 +++++++++++++++++++++ bin/git-rename-branch.sh | 4 ++++ 2 files changed, 25 insertions(+) create mode 100755 bin/git-delete-branch.sh diff --git a/bin/git-delete-branch.sh b/bin/git-delete-branch.sh new file mode 100755 index 000000000..fd947e458 --- /dev/null +++ b/bin/git-delete-branch.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +branch=$1 +if [ -z "$branch" ]; then + echo "ERROR: No branch name given." + exit 1 +fi + +# Force delete if not merged +if ! git branch -D "$branch"; then + echo "ERROR: Failed to delete local branch $branch with -D flag." + exit 1 +fi + +# Delete remote branch +if ! git push origin --delete "$branch"; then + echo "ERROR: Failed to delete remote branch $branch" + exit 1 +fi + +echo "Branch $branch deleted." diff --git a/bin/git-rename-branch.sh b/bin/git-rename-branch.sh index 5e866f977..cd6a8def9 100755 --- a/bin/git-rename-branch.sh +++ b/bin/git-rename-branch.sh @@ -15,9 +15,13 @@ rename_branch() { branch_new=$2 echo "Renaming $branch to $branch_new" echo git branch -m "$branch" "$branch_new" + git branch -m "$branch" "$branch_new" echo git push origin "$branch_new" + git push origin "$branch_new" echo git push origin --delete "$branch" + git push origin --delete "$branch" echo git push --set-upstream origin "$branch_new" + git push --set-upstream origin "$branch_new" } nargs=$#