Skip to content

Commit

Permalink
imp - Should work with spaces
Browse files Browse the repository at this point in the history
---

pushrepos and uprepos should work with folders with spaces in them.

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Oct 20, 2024
1 parent 7949ea4 commit a19264e
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions pushrepos
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,35 @@
#

if ! command -v tput &> /dev/null; then
AQUA=""
ORANGE=""
RESET=""
AQUA=""
ORANGE=""
RESET=""
else
AQUA=$(tput setaf 45)
ORANGE=$(tput setaf 214)
RESET=$(tput sgr0)
AQUA=$(tput setaf 45)
ORANGE=$(tput setaf 214)
RESET=$(tput sgr0)
fi

enum_and_push() {
universal_commit_msg=$2
[[ -z $2 ]] && universal_commit_msg="General changes"
readarray -t maybe_gits < <( find "$1" -maxdepth 1 -name "*" -type d )
for maybe_git in "${maybe_gits[@]}"
do
if [[ ! -e "$maybe_git/.git" ]]; then
echo "${ORANGE}[*] ${RESET}Repo $maybe_git is not a git repo. Refusing to push..."
continue
fi
echo "${AQUA}[+] ${RESET}Pushing to $maybe_git..."
git -C $maybe_git add -A .
git -C $maybe_git commit -m "$universal_commit_msg"
git -C $maybe_git push
echo "${AQUA}[+] ${RESET}Push of $maybe_git done."
done
universal_commit_msg=$2
[[ -z $2 ]] && universal_commit_msg="General changes"
readarray -t maybe_gits < <( find "$1" -maxdepth 1 -name "*" -type d )
for maybe_git in "${maybe_gits[@]}"
do
if [[ ! -e "$maybe_git/.git" ]]; then
echo "${ORANGE}[*] ${RESET}Repo $maybe_git is not a git repo. Refusing to push..."
continue
fi
echo "${AQUA}[+] ${RESET}Pushing to $maybe_git..."
git -C "$maybe_git" add -A .
git -C "$maybe_git" commit -m "$universal_commit_msg"
git -C "$maybe_git" push
echo "${AQUA}[+] ${RESET}Push of $maybe_git done."
done
}

if [[ -z $1 ]]; then
echo "${ORANGE}[!] ${RESET}Specify git directory containing all repositories and, optionally, a universal commit message."
echo "${ORANGE}[!] ${RESET}Specify git directory containing all repositories and, optionally, a universal commit message."
else
enum_and_push $1 "$2"
enum_and_push "$1" "$2"
fi

0 comments on commit a19264e

Please sign in to comment.