-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.sh
executable file
·192 lines (142 loc) · 3.16 KB
/
git.sh
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/bash
# Created: 28.09.2016
# Vladimir Vons, VladVons@gmail.com
User="VladVons"
Name="py-relay"
Mail="vladvons@gmail.com"
#
#Branch="master"
Branch="v3"
#
Url="https://github.com/$User/$Name.git"
Log()
{
aMsg="$1";
Msg="$(date +%Y-%m-%d-%a), $(date +%H:%M:%S), $(id -u -n), $aMsg"
echo "$Msg"
}
Clean()
{
echo "delete objects"
find ./ \( -name "*.pyc" -o -name "*.log" -o -name "*.pyi" -o -name "*.db" \) -type f -delete
find ./ \( -name '*.so' -o -name "*.exe" \) -type f -delete
#find . -name '*.log' -exec rm -v -f -R {} \;
#find . -name '*.log' -exec rm -v -f -R {} \;
find . -name '__pycache__' -exec rm -v -f -R {} \;
echo
echo "Statistics *.py"
#find . -name '*.py' -ls | awk '{total += $7} END {print total}'
find . -name '*.py' | xargs wc | cat -n
#find . -name '*.py' | wc -l
#echo
#du -s -b py-relay/src/* | sort -n -r
#find py-relay/src/ -ls -type f | awk '{sum += $7} END {print sum}'
#echo
#echo "Files *.py"
#echo
#echo "Statistics *.json"
#find . -name '*.json' | xargs wc
}
GitAuth()
{
Log "$0->$FUNCNAME"
sudo chown -R $USER .
# sign with eMail
git config --global user.email $Mail
git config --global user.name $User
# no password
git config --global credential.helper 'cache --timeout=36000'
}
GitCreate()
{
Log "$0->$FUNCNAME"
# create new project on disk
git init
GitAuth
# remote git server location
git remote add origin $Url
}
GitClone()
{
Log "$0->$FUNCNAME"
# restore clone copy fromserver to disk
git clone --single-branch -b $Branch $Url
GitAuth
#web admin access here
#https://github.com/VladVons/appman
}
GitFromServMissed()
{
git fetch --all
git reset --hard origin/$Branch
#
git ls-files -d | xargs git checkout --
}
GitSyncToServ()
# sync only changes from disk to server
{
aComment="$1";
Log "$0->$FUNCNAME"
git status
#git add install.sh
#git rm TestClient.py
#git mv README.md README
#git log
git add -u -v
git commit -a -m "$aComment"
git push -u origin $Branch
}
GitFromServ()
# sync changes from server to disk
{
Log "$0->$FUNCNAME"
git pull origin $Branch
}
GitToServ()
# sync changes from disk to serv
{
aComment=${1:-"MyCommit"};
Log "$0->$FUNCNAME"
Clean
# add all new files
git add -A -v
GitSyncToServ "$aComment"
}
GitNewBranch()
# sync changes from disk to serv
{
Log "$0->$FUNCNAME"
git checkout -b $Branch
#GitSyncToServ
}
GitReset()
{
Log "$0->$FUNCNAME"
git checkout --orphan TEMP_BRANCH
git add -A
git commit -am "Initial commit"
git branch -D $Branch
git branch -m $Branch
git push -f origin $Branch
}
Diff()
{
diff -r dir1 dir2 | sed '/Binary\ files\ /d' > diff.txt
}
Help()
{
echo "Unknown option"
}
#GitUpdate
clear
case $1 in
Clean) "$1" "$2" "$3" ;;
GitAuth) "$1" "$2" "$3" ;;
GitCreate) "$1" "$2" "$3" ;;
GitToServ|t) GitToServ "$2" "$3" ;;
GitFromServ|f) GitFromServ "$2" "$3" ;;
GitFromServMissed|m) GitFromServMissed "$2" "$3" ;;
GitNewBranch) "$1" "$2" "$3" ;;
GitClone) "$1" "$2" "$3" ;;
*) Help ;;
esac