-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgitinit
executable file
·55 lines (54 loc) · 1.33 KB
/
gitinit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
CommitterName=ETERNALBLUEbullrun
ProjectName=${PWD##*/}
BranchName=trunk
set -x
for arg in "$@"; do
shift
IFS== read -r Opt Val <<< "$arg"
if [ -z "$Opt" ]; then
Opt = $arg
fi
echo "$arg : $Opt = $Val"
case "$Opt" in
"--committer") set -- "$@" "-c$Val" ;;
"--project") set -- "$@" "-p$Val" ;;
"--branch") set -- "$@" "-b$Val" ;;
"--force") set -- "$@" "-f" ;;
"--clean") set -- "$@" "-l" ;;
*) set -- "$@" "$Opt$Val" ;;
esac
done
while getopts c:p:b:fl argv; do
echo "$argv = $OPTARG"
case $argv in
c) CommitterName=${OPTARG}
;; p) ProjectName=${OPTARG}
;; b) BranchName=${OPTARG}
;; f)
if test -d ".git/"; then
read -p "ReMove `pwd`/.git/? [y/n]: " input
if [ "y" == "$input" ]; then
rm -f .git/objects/*/*
rm -r .git/
fi
fi
;; l)
read -p "ReMove `pwd`/*? (will rm setup.sh if it exists!) [y/n]: " input
if [ "y" == "$input" ]; then
# mv "$0" ../
rm *
# mv "../$0" "./" #TODO: fix for source'd scripts
fi
;; *) echo "Invalid argument: '$argv'"
;;esac
done
if test -d ".git/"; then
echo "Found `pwd`/.git/, re-run with --force to replace it."
else
git init
sed -i'' "s/https:\/\//ssh:\/\/git\@/g" .git/config
git remote add origin ssh://[email protected]
git remote set-url origin ssh://[email protected]/$CommitterName/$ProjectName\.git
git fetch origin
git switch $BranchName
fi