Skip to content

Commit

Permalink
small script updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-eraigosa committed Apr 2, 2024
1 parent de9f91f commit 8eab687
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
31 changes: 25 additions & 6 deletions opt/bin/git-rm-mybranches.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
#!/bin/bash

# set -x -v

# clean up the current users branches
set -e
export MY_USER="${MY_USER:-$(whoami)}"
export SEARCH_TERM="${SEARCH_TERM:-}"


# make sure before moving forward
if [ ! "$1" = "--force" ]; then
if [ "$1" = "--force" ]; then
cleanup="Y"
fi

if [ "${cleanup}" = "Y" ]; then
SEARCH_TERM="${2}"
fi

if [ -n "${1}" ]; then
SEARCH_TERM="${1}"
fi

if [ -z "${SEARCH_TERM}" ]; then
echo "Usage: $o [--force] regex"
exit 1
fi

if [ ! "${cleanup}" = "Y" ]; then
echo "Current directory $(pwd) and repo $(git rev-parse --show-toplevel)"
echo -n "Would you like to cleanup ($(printf '%s' $(git branch -l 2>&1 |grep "^\s\s${MY_USER}\/.*"|wc -l))) all branches? [Y]:" && \
echo -n "Would you like to cleanup ($(printf '%s' $(git branch -l 2>&1 |grep "^\s\s${SEARCH_TERM}"|wc -l))) all branches? [Y]:" && \
read -r cleanup
else
cleanup="Y"
fi

# this depends on branches starting with the logged in users user name
for b in $(git branch -l 2>&1 |grep "^\s\s${MY_USER}\/.*"); do
for b in $(git branch -l 2>&1 |grep "^\s\s${SEARCH_TERM}"); do
echo "Cleaning up branch $b";
if [ "${cleanup}" = "Y" ]; then
git branch -D $b
Expand Down
1 change: 1 addition & 0 deletions opt/profiles/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ brew 'pyenv'

# setup vault
brew 'vault'
brew 'kubeconform'

0 comments on commit 8eab687

Please sign in to comment.