bin/git: improve branch handling

This commit is contained in:
xeruf 2021-11-10 17:23:46 +01:00
parent d534e538af
commit 3ebfcbe07d
3 changed files with 9 additions and 6 deletions

View File

@ -21,7 +21,7 @@ case $command in
git aur push --amend;; git aur push --amend;;
(push) (push)
makepkg --printsrcinfo > .SRCINFO makepkg --printsrcinfo > .SRCINFO
git add -f .SRCINFO *.install >/dev/null || true git add -f .SRCINFO *.install 2>/dev/null || true
git commit -v -a "$@" git commit -v -a "$@"
git push;; git push;;
esac esac

View File

@ -1,7 +1,10 @@
#!/bin/sh #!/bin/sh
# Removes the given branch locally and remotely. # Remove the given branch locally and remotely.
# With no argument it switches to the default branch and deletes the current branch. # Without argument delete the current branch after switching to the default branch.
branch=${1:-$(git curbranch)} branch=${1:-$(git curbranch)}
echo "${@:-$branch}" | sed 's/\([^ ]\+\)/\1@{push}/g' | xargs git rev-parse --abbrev-ref --revs-only | sed 's/\// /' | xargs --no-run-if-empty git push -d echo "${@:-$branch}" | sed 's/\([^ ]\+\)/\1@{push}/g' |
test -n "$1" || git checkout main || git checkout master || git checkout $(cat "$(git rev-parse --git-path refs/remotes/origin/HEAD)" | sed 's|.*/||') xargs git rev-parse --abbrev-ref --revs-only | sed 's/\// /' |
xargs -L 1 --no-run-if-empty git push -d
test -n "$1" || git checkout main || git checkout master ||
git checkout $(cat "$(git rev-parse --git-path refs/remotes/origin/HEAD)" | sed 's|.*/||')
git branch -D "${@:-$branch}" git branch -D "${@:-$branch}"

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# Cleans up remote branches and removes branches where the remote-tracking branches got removed. # Cleans up remote branches and removes branches where the remote-tracking branches got removed.
git fetch --prune && git fetch --all --prune &&
for branch in `git branch -vv | grep ": gone]" | cut -d" " -f3` for branch in `git branch -vv | grep ": gone]" | cut -d" " -f3`
do git branch -D "$branch" do git branch -D "$branch"
done done