-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-gitcommitpush
More file actions
executable file
·170 lines (145 loc) · 3.25 KB
/
github-gitcommitpush
File metadata and controls
executable file
·170 lines (145 loc) · 3.25 KB
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
#!/bin/bash
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
blue=`tput setaf 4`
magenta=`tput setaf 5`
cyan=`tput setaf 6`
white=`tput setaf 7`
reset=`tput sgr0`
dir=$(dirname "$0")
cd $dir
reponame="xml_parser_c"
user="fedoseevav"
pass=$(<../../github_apppass.txt)
scriptname=$(basename "$0")
echo ""
echo ""
echo "${yellow}Wellcome to the git-script! The constants below will be used."
echo "To edit them use text editor programm."
echo ""
echo "${white}reponame: ${reset}$reponame"
echo "${white}user: ${reset}$user"
echo "${white}pass: ${reset}$pass"
echo "${white}filename: ${reset}$scriptname"
echo "${white}directory: ${reset}$dir"
# Check password is empty
if [ -z "$pass" ];
then
echo ""
echo "${red}Password not set. Please edit ${white}pass${red} constant and try again.${reset}"
echo "${red}exiting...${reset}";
exit 0
fi
# Shoosing an option
def_option="0"
echo ""
echo "${yellow}Shoose an option (default is 0):"
echo "${cyan}Exit -> ${white}0"
echo "${cyan}Only Commit -> ${white}1"
echo "${cyan}Only Push -> ${white}2"
echo "${cyan}Commit + Push -> ${white}3${reset}"
echo "${cyan}Create github repository -> ${white}-1${reset}"
read option;
case $option in
0)
echo "${yellow}exiting...${reset}";
echo ""
echo ""
echo ""
echo ""
exit 0;;
-1)
# Create new repository on the bitbucket server
echo "${cyan}curl ${yellow}-i -u ${white}$user:$pass${reset}";
#curl -i -u $user:$pass "https://api.bitbucket.org/2.0/repositories/$company/$reponame" -H "Content-Type: application/json" -d "{\"scm\": \"git\", \"is_private\": \"true\", \"fork_policy\": \"no_public_forks\", \"project\": {\"key\": \"$project_key\"}}"
echo "${yellow}exiting...${reset}";
echo ""
echo ""
echo ""
echo ""
exit 0
;;
esac
#
#
# git init
# git remote -v
# git remote add origin "git@github.com:${user}/$reponame.git" // if need
#
#
echo ""
echo "${cyan}git ${white}init${reset}";
git init
echo ""
echo "${cyan}git ${white}remote ${yellow}-v${reset}";
git remote -v
output=$(git remote -v)
if [ -z "$output" ];
then
echo ""
echo "${yellow}No remotes adding origin...${reset}"
echo "${cyan}git ${white}remote add origin ${yellow}\"https://${user}:${pass}@github.com/${user}/$reponame.git\"${reset}"
git remote add origin "https://${user}:${pass}@github.com/$user/$reponame.git"
else
echo ""
echo "${yellow}Remote exists...${reset}"
fi;
#
#
# git commit -m message
#
#
case $option in
1|3)
echo "${yellow}Message for commit or 'n' to exit${reset}"
read commitmessage;
case $commitmessage in
n)
echo "${yellow}exiting...${reset}";
echo ""
echo ""
echo ""
echo ""
exit 0
;;
esac
echo ""
echo "${cyan}git ${white}add ${red}. ${yellow}-v${reset}";
git add . -v
echo ""
echo "${cyan}git ${white}commit ${red}-m ${yellow}\"$commitmessage\"${reset}";
git commit -m "$commitmessage"
;;
esac
#
#
# exit only commit
#
#
case $option in
1)
echo "${yellow}exiting...${reset}";
echo ""
echo ""
echo ""
echo ""
exit 0
;;
esac
#
#
# git push -u origin master -v
#
#
case $option in
2|3)
echo ""
echo "${cyan}git ${white}push ${yellow} ${white}origin main ${yellow}-v ${reset}";
git push -u origin main -v
;;
esac
echo ""
echo ""
echo ""
echo ""