♻️ Refactored based off of remote handling
This commit is contained in:
parent
e618f80155
commit
e2a821aa08
1 changed files with 14 additions and 28 deletions
38
scripts/bgit
38
scripts/bgit
|
|
@ -17,12 +17,17 @@ txtyellow=${txtbld}$(tput setaf 3)
|
||||||
txtwhite=${txtbld}$(tput setaf 7)
|
txtwhite=${txtbld}$(tput setaf 7)
|
||||||
|
|
||||||
# Dependency check
|
# Dependency check
|
||||||
if ! command -v git &> /dev/null
|
dependencies=("xclip" "git")
|
||||||
|
numdependencies=2
|
||||||
|
missingdependencies=0
|
||||||
|
for ((i = 0; i < numdependencies; i++)) ;
|
||||||
|
do
|
||||||
|
if ! command -v "${dependencies[$i]}" &> /dev/null
|
||||||
then
|
then
|
||||||
echo "${txtred}dependency not met: git"
|
echo "${txtred}dependency not met: ${dependencies[$i]}${txtwhite}"
|
||||||
echo "Please install needed depndencies${txtwhite}"
|
missingdependencies=$((missingdependencies+1))
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Intro Prompt
|
# Intro Prompt
|
||||||
echo "${txtblue}bgit: a handy shell script for automating simple git inits/commits"
|
echo "${txtblue}bgit: a handy shell script for automating simple git inits/commits"
|
||||||
|
|
@ -199,21 +204,10 @@ if [ $numrepos -eq 0 ] ; then
|
||||||
if [[ $crepo == 'y' || $crepo == 'yes' ]] ; then
|
if [[ $crepo == 'y' || $crepo == 'yes' ]] ; then
|
||||||
|
|
||||||
# Dependency check
|
# Dependency check
|
||||||
dependencies=("xclip" "curl")
|
if ! command -v curl &> /dev/null
|
||||||
numdependencies=2
|
|
||||||
missingdependencies=0
|
|
||||||
for ((i = 0; i < numdependencies; i++)) ;
|
|
||||||
do
|
|
||||||
if ! command -v "${dependencies[$i]}" &> /dev/null
|
|
||||||
then
|
then
|
||||||
echo "${txtred}dependency not met: ${dependencies[$i]}${txtwhite}"
|
echo "${txtred}dependency not met: curl"
|
||||||
missingdependencies=$((missingdependencies+1))
|
echo "Please install needed depndencies${txtwhite}"
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ $missingdependencies -gt 0 ] ;
|
|
||||||
then
|
|
||||||
echo "${txtred}Please install needed dependencies${txtwhite}"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -249,8 +243,6 @@ if [ $numrepos -eq 0 ] ; then
|
||||||
# Otherwise, if there already is a .git directory...
|
# Otherwise, if there already is a .git directory...
|
||||||
else
|
else
|
||||||
|
|
||||||
# creates a list of repos and puts them in an array
|
|
||||||
# remotearray=($(git remote))
|
|
||||||
# Grabs all new files
|
# Grabs all new files
|
||||||
newfiles=$(git status --short | grep '??' | awk '{print $2}' | tr '\n' ' ')
|
newfiles=$(git status --short | grep '??' | awk '{print $2}' | tr '\n' ' ')
|
||||||
# Grabs all modified files
|
# Grabs all modified files
|
||||||
|
|
@ -297,9 +289,6 @@ else
|
||||||
|
|
||||||
# and pushes it to remote repository
|
# and pushes it to remote repository
|
||||||
git remote | xargs -L1 git push --all
|
git remote | xargs -L1 git push --all
|
||||||
# for ((i = 0; i < numrepos; i++)) ; do
|
|
||||||
# git push --force ${remotearray[i]} ;
|
|
||||||
# done
|
|
||||||
|
|
||||||
echo "${txtblue}bgit script has completed! goodbye!${txtwhite}"
|
echo "${txtblue}bgit script has completed! goodbye!${txtwhite}"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
@ -401,9 +390,6 @@ else
|
||||||
|
|
||||||
# pushes the commit to each repository
|
# pushes the commit to each repository
|
||||||
git remote | xargs -L1 git push --all
|
git remote | xargs -L1 git push --all
|
||||||
# for ((i = 0; i < numrepos; i++)) ; do
|
|
||||||
# git push ${remotearray[i]} ;
|
|
||||||
# done
|
|
||||||
|
|
||||||
echo "${txtblue}bgit script has completed! goodbye!${txtwhite}"
|
echo "${txtblue}bgit script has completed! goodbye!${txtwhite}"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue