-
Notifications
You must be signed in to change notification settings - Fork 2
/
dzgit
executable file
·208 lines (176 loc) · 6.73 KB
/
dzgit
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/sh
if [ -z "$1" ] || [ \( "$1" == "release" -a "$#" != 3 \) ] || [ \( "$1" == "merge" -a "$#" != 3 \) ] || [ \( "$1" == "checkout" -a "$#" != 2 \) ]; then
echo "=========================================================================="
echo " 使い方"
echo "--------------------------------------------------------------------------"
echo "以下を選択して、右クリックでコマンドに貼り付けてください"
echo ""
echo "▼新しい作業用ブランチの作成"
echo "dzgit [チケットの番号]_[チケットの意味]"
echo "例) dzgit 1111_fix_profile_photo"
echo ""
echo "▼リリース用ブランチの作成"
echo "dzgit release [生成元ブランチ名] [生成ブランチ名]"
echo "例) dzgit release master 20120412_profile_photo"
echo ""
echo "▼ブランチのマージ"
echo "dzgit merge [マージ先ブランチ名] [マージしたいブランチ名(,区切りで複数指定可)]"
echo "例) dzgit merge release/20120410_bugfixes feature/1111_fix_profile_photo"
echo " dzgit merge release/20120410_bugfixes XXX,YYY,ZZZ"
echo ""
echo "▼新しいブランチのチェックアウト"
echo "dzgit checkout [ブランチ名]"
echo "例) dzgit checkout feature/15253_video"
echo "=========================================================================="
exit
fi
if [ "$1" == "merge" ]; then
git status
IFS=','
echo "=========================================================================="
echo " "$2"ブランチに"$3"ブランチをマージしていいですか? [y/n]"
echo "--------------------------------------------------------------------------"
echo "git fetch origin"
for branch in $3; do
echo "git checkout -b "$branch" origin/"$branch
echo "git checkout "$branch
echo "git pull origin "$branch
done
echo "git checkout -b "$2" origin/"$2
echo "git checkout "$2
echo "git pull origin "$2
for branch in $3; do
echo "git merge --no-ff "$branch
done
echo "--------------------------------------------------------------------------"
read ans
if [ "$ans" != "y" ]; then
echo "キャンセルしました"
echo "=========================================================================="
git status
exit
fi
echo "=========================================================================="
echo " "$3" -> "$2" マージされます。本当にいいですか? [y/n]"
echo "=========================================================================="
read ans
if [ "$ans" != "y" ]; then
echo "キャンセルしました"
echo "=========================================================================="
git status
exit
fi
git fetch origin
for branch in $3; do
git checkout -b $branch origin/$branch
git checkout $branch
git pull origin $branch
done
git checkout -b $2 origin/$2
git checkout $2
git pull origin $2
echo "=========================================================================="
echo " マージ準備完了。マージします。"
echo "=========================================================================="
for branch in $3; do
git merge --no-ff $branch
done
echo "--------------------------------------------------------------------------"
echo " "$2"ブランチをマージしました"
echo "問題がなさそうならgit pushをしてください"
echo "=========================================================================="
git status
exit
fi
if [ "$1" == "release" ]; then
echo "=========================================================================="
echo " "$2"から、リリース用ブランチ release/"$3" を作っていいですか? [y/n]"
echo "--------------------------------------------------------------------------"
echo "git fetch origin"
echo "git checkout "$2
echo "git pull origin "$2
echo "git branch release/"$3
echo "git checkout release/"$3
echo "git push origin release/"$3
echo "git branch -a"
echo "=========================================================================="
read ans
if [ "$ans" != "y" ]; then
echo "キャンセルしました"
echo "=========================================================================="
git status
exit
fi
echo "=========================================================================="
echo " "$2" ==> release/"$3" 本当にいいですか? [y/n]"
echo "=========================================================================="
read ans
if [ "$ans" != "y" ]; then
echo "キャンセルしました"
echo "=========================================================================="
git status
exit
fi
git fetch origin
git checkout $2
git pull origin $2
git branch release/$3
git checkout release/$3
git push origin release/$3
git branch -a
echo "--------------------------------------------------------------------------"
echo " リリース用ブランチ release/"$3" を作りました"
echo "=========================================================================="
git status
exit
fi
if [ "$1" == "checkout" ]; then
echo "=========================================================================="
echo " "$2"をチェックアウトしていいですか? [y/n]"
echo "--------------------------------------------------------------------------"
echo "git fetch origin"
echo "git checkout -b "$2" origin/"$2
echo "git checkout "$2
echo "=========================================================================="
read ans
if [ "$ans" != "y" ]; then
echo "キャンセルしました"
echo "=========================================================================="
git status
exit
fi
git fetch origin
git checkout -b $2 origin/$2
git checkout $2
git status
exit
fi
echo "=========================================================================="
echo " 作業用ブランチ feature/"$1" を作っていいですか? [y/n]"
echo "--------------------------------------------------------------------------"
echo "git fetch origin"
echo "git checkout master"
echo "git pull origin master"
echo "git branch feature/"$1
echo "git checkout feature/"$1
echo "git push origin feature/"$1
echo "git branch -a"
echo "=========================================================================="
read ans
if [ "$ans" != "y" ]; then
echo "キャンセルしました"
echo "=========================================================================="
git status
exit
fi
git fetch origin
git checkout master
git pull origin master
git branch feature/$1
git checkout feature/$1
git push origin feature/$1
git branch -a
echo "--------------------------------------------------------------------------"
echo " 作業用ブランチ feature/"$1" を作りました"
echo "=========================================================================="
git status