83 lines
1.5 KiB
Bash
Executable file
83 lines
1.5 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
# new repo
|
|
create() {
|
|
|
|
dir=$(basename $(pwd))
|
|
user="visone"
|
|
|
|
# config credentials
|
|
|
|
git config --global user.name "Victor Tebar"
|
|
git config --global user.email "victortebar@gmail.com"
|
|
|
|
|
|
# Initialize repo
|
|
if [ -f .git/config ]
|
|
then
|
|
printf "This si already a git repo!!!"
|
|
exit
|
|
else
|
|
|
|
git init
|
|
|
|
case "$2" in
|
|
|
|
gitea)
|
|
# crating repo gitea
|
|
|
|
git remote add origin git@gitea.com:$user/"$dir".git
|
|
git push origin main ;;
|
|
|
|
gitlab)
|
|
# creating repo gitlab
|
|
|
|
git remote add origin git@gitlab.com:$user/"$dir".git
|
|
git push origin main ;;
|
|
esac
|
|
|
|
# adding all files and setting first commit
|
|
|
|
git add .
|
|
git commit -m "First commit"
|
|
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
update() {
|
|
|
|
printf "Your're about to commit your changes in:\n\t\tBranch: "$(git branch --show-current)"\n\t\tRepo "$(basename $(pwd))"\n\t\tAre you sure? Y/N\n"
|
|
read op
|
|
if [ "$op" = y ]
|
|
then
|
|
git add .
|
|
printf "Write commit:\n"
|
|
read commit
|
|
git commit -m "$commit"
|
|
if [ "$(git remote -v | awk 'NR==1 { print $1}')" = "all" ]
|
|
then
|
|
git push all "$(git branch --show-current)"
|
|
else
|
|
git push origin "$(git branch --show-current)"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
|
|
hp (){
|
|
|
|
printf "\n ##### Help #####\n"
|
|
printf "\nUsage:\nTo use this script you need to pass it some
|
|
options.\n\n\tOptions:\n\t\t$(basename $0) -c it will create a new repo in the "$(basename $(pwd))" dir \n\t\t$(basename $0) -u it will update the "$(basename $(pwd))" repo\n\t\t$(basename $0) -h show this help"
|
|
|
|
}
|
|
|
|
case "$1" in
|
|
-c) create ;;
|
|
-u) update ;;
|
|
*) hp ;;
|
|
esac
|