Skip to content

Commit 15aab26

Browse files
committed
Use git_do where appropriate
1 parent 5bca8d9 commit 15aab26

File tree

5 files changed

+92
-92
lines changed

5 files changed

+92
-92
lines changed

git-flow-feature

+29-29
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ cmd_start() {
204204

205205
# update the local repo with remote changes, if asked
206206
if flag fetch; then
207-
git fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
207+
git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
208208
fi
209209

210210
# if the origin branch counterpart exists, assert that the local branch
@@ -214,7 +214,7 @@ cmd_start() {
214214
fi
215215

216216
# create branch
217-
if ! git checkout -b "$BRANCH" "$BASE"; then
217+
if ! git_do checkout -b "$BRANCH" "$BASE"; then
218218
die "Could not create feature branch '$BRANCH'"
219219
fi
220220

@@ -287,8 +287,8 @@ cmd_finish() {
287287
# update local repo with remote changes first, if asked
288288
if has "$ORIGIN/$BRANCH" $(git_remote_branches); then
289289
if flag fetch; then
290-
git fetch -q "$ORIGIN" "$BRANCH"
291-
git fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
290+
git_do fetch -q "$ORIGIN" "$BRANCH"
291+
git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
292292
fi
293293
fi
294294

@@ -311,16 +311,16 @@ cmd_finish() {
311311
fi
312312

313313
# merge into BASE
314-
git checkout "$DEVELOP_BRANCH"
314+
git_do checkout "$DEVELOP_BRANCH"
315315
if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
316-
git merge --ff "$BRANCH"
316+
git_do merge --ff "$BRANCH"
317317
else
318318
if noflag squash; then
319-
git merge --no-ff "$BRANCH"
319+
git_do merge --no-ff "$BRANCH"
320320
else
321-
git merge --squash "$BRANCH"
322-
git commit
323-
git merge "$BRANCH"
321+
git_do merge --squash "$BRANCH"
322+
git_do commit
323+
git_do merge "$BRANCH"
324324
fi
325325
fi
326326

@@ -351,15 +351,15 @@ helper_finish_cleanup() {
351351

352352
# delete branch
353353
if flag fetch; then
354-
git push "$ORIGIN" ":refs/heads/$BRANCH"
354+
git_do push "$ORIGIN" ":refs/heads/$BRANCH"
355355
fi
356356

357357

358358
if noflag keep; then
359359
if flag force_delete; then
360-
git branch -D "$BRANCH"
360+
git_do branch -D "$BRANCH"
361361
else
362-
git branch -d "$BRANCH"
362+
git_do branch -d "$BRANCH"
363363
fi
364364
fi
365365

@@ -383,17 +383,17 @@ cmd_publish() {
383383
# sanity checks
384384
require_clean_working_tree
385385
require_branch "$BRANCH"
386-
git fetch -q "$ORIGIN"
386+
git_do fetch -q "$ORIGIN"
387387
require_branch_absent "$ORIGIN/$BRANCH"
388388

389389
# create remote branch
390-
git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
391-
git fetch -q "$ORIGIN"
390+
git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
391+
git_do fetch -q "$ORIGIN"
392392

393393
# configure remote tracking
394-
git config "branch.$BRANCH.remote" "$ORIGIN"
395-
git config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
396-
git checkout "$BRANCH"
394+
git_do config "branch.$BRANCH.remote" "$ORIGIN"
395+
git_do config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
396+
git_do checkout "$BRANCH"
397397

398398
echo
399399
echo "Summary of actions:"
@@ -410,11 +410,11 @@ cmd_track() {
410410
# sanity checks
411411
require_clean_working_tree
412412
require_branch_absent "$BRANCH"
413-
git fetch -q "$ORIGIN"
413+
git_do fetch -q "$ORIGIN"
414414
require_branch "$ORIGIN/$BRANCH"
415415

416416
# create tracking branch
417-
git checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
417+
git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
418418

419419
echo
420420
echo "Summary of actions:"
@@ -445,7 +445,7 @@ cmd_checkout() {
445445

446446
if [ "$NAME" != "" ]; then
447447
expand_nameprefix_arg
448-
git checkout "$BRANCH"
448+
git_do checkout "$BRANCH"
449449
else
450450
die "Name a feature branch explicitly."
451451
fi
@@ -464,12 +464,12 @@ cmd_rebase() {
464464
require_clean_working_tree
465465
require_branch "$BRANCH"
466466

467-
git checkout -q "$BRANCH"
467+
git_do checkout -q "$BRANCH"
468468
local OPTS=
469469
if flag interactive; then
470470
OPTS="$OPTS -i"
471471
fi
472-
git rebase $OPTS "$DEVELOP_BRANCH"
472+
git_do rebase $OPTS "$DEVELOP_BRANCH"
473473
}
474474

475475
avoid_accidental_cross_branch_action() {
@@ -511,20 +511,20 @@ cmd_pull() {
511511
# we already have a local branch called like this, so simply pull the
512512
# remote changes in
513513
if flag rebase; then
514-
if ! git pull --rebase -q "$REMOTE" "$BRANCH"; then
514+
if ! git_do pull --rebase -q "$REMOTE" "$BRANCH"; then
515515
warn "Pull was aborted. There might be conflicts during rebase or '$REMOTE' might be inaccessible."
516516
exit 1
517517
fi
518518
else
519-
git pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'."
519+
git_do pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'."
520520
fi
521521

522522
echo "Pulled $REMOTE's changes into $BRANCH."
523523
else
524524
# setup the local branch clone for the first time
525-
git fetch -q "$REMOTE" "$BRANCH" || die "Fetch failed." # stores in FETCH_HEAD
526-
git branch --no-track "$BRANCH" FETCH_HEAD || die "Branch failed."
527-
git checkout -q "$BRANCH" || die "Checking out new local branch failed."
525+
git_do fetch -q "$REMOTE" "$BRANCH" || die "Fetch failed." # stores in FETCH_HEAD
526+
git_do branch --no-track "$BRANCH" FETCH_HEAD || die "Branch failed."
527+
git_do checkout -q "$BRANCH" || die "Checking out new local branch failed."
528528
echo "Created local branch $BRANCH based on $REMOTE's $BRANCH."
529529
fi
530530
}

git-flow-hotfix

+19-19
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ cmd_start() {
169169
require_branch_absent "$BRANCH"
170170
require_tag_absent "$VERSION_PREFIX$VERSION"
171171
if flag fetch; then
172-
git fetch -q "$ORIGIN" "$MASTER_BRANCH"
172+
git_do fetch -q "$ORIGIN" "$MASTER_BRANCH"
173173
fi
174174
if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then
175175
require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
176176
fi
177177

178178
# create branch
179-
git checkout -b "$BRANCH" "$BASE"
179+
git_do checkout -b "$BRANCH" "$BASE"
180180

181181
echo
182182
echo "Summary of actions:"
@@ -199,17 +199,17 @@ cmd_publish() {
199199
# sanity checks
200200
require_clean_working_tree
201201
require_branch "$BRANCH"
202-
git fetch -q "$ORIGIN"
202+
git_do fetch -q "$ORIGIN"
203203
require_branch_absent "$ORIGIN/$BRANCH"
204204

205205
# create remote branch
206-
git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
207-
git fetch -q "$ORIGIN"
206+
git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
207+
git_do fetch -q "$ORIGIN"
208208

209209
# configure remote tracking
210210
git config "branch.$BRANCH.remote" "$ORIGIN"
211211
git config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
212-
git checkout "$BRANCH"
212+
git_do checkout "$BRANCH"
213213

214214
echo
215215
echo "Summary of actions:"
@@ -226,11 +226,11 @@ cmd_track() {
226226
# sanity checks
227227
require_clean_working_tree
228228
require_branch_absent "$BRANCH"
229-
git fetch -q "$ORIGIN"
229+
git_do fetch -q "$ORIGIN"
230230
require_branch "$ORIGIN/$BRANCH"
231231

232232
# create tracking branch
233-
git checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
233+
git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
234234

235235
echo
236236
echo "Summary of actions:"
@@ -260,9 +260,9 @@ cmd_finish() {
260260
require_branch "$BRANCH"
261261
require_clean_working_tree
262262
if flag fetch; then
263-
git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
263+
git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
264264
die "Could not fetch $MASTER_BRANCH from $ORIGIN."
265-
git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
265+
git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
266266
die "Could not fetch $DEVELOP_BRANCH from $ORIGIN."
267267
fi
268268
if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then
@@ -276,9 +276,9 @@ cmd_finish() {
276276
# in case a previous attempt to finish this release branch has failed,
277277
# but the merge into master was successful, we skip it now
278278
if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
279-
git checkout "$MASTER_BRANCH" || \
279+
git_do checkout "$MASTER_BRANCH" || \
280280
die "Could not check out $MASTER_BRANCH."
281-
git merge --no-ff "$BRANCH" || \
281+
git_do merge --no-ff "$BRANCH" || \
282282
die "There were merge conflicts."
283283
# TODO: What do we do now?
284284
fi
@@ -294,7 +294,7 @@ cmd_finish() {
294294
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
295295
[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
296296
[ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
297-
eval git tag $opts "$VERSION_PREFIX$VERSION" "$BRANCH" || \
297+
eval git_do tag $opts "$VERSION_PREFIX$VERSION" "$BRANCH" || \
298298
die "Tagging failed. Please run finish again to retry."
299299
fi
300300
fi
@@ -303,28 +303,28 @@ cmd_finish() {
303303
# in case a previous attempt to finish this release branch has failed,
304304
# but the merge into develop was successful, we skip it now
305305
if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then
306-
git checkout "$DEVELOP_BRANCH" || \
306+
git_do checkout "$DEVELOP_BRANCH" || \
307307
die "Could not check out $DEVELOP_BRANCH."
308308

309309
# TODO: Actually, accounting for 'git describe' pays, so we should
310310
# ideally git merge --no-ff $tagname here, instead!
311-
git merge --no-ff "$BRANCH" || \
311+
git_do merge --no-ff "$BRANCH" || \
312312
die "There were merge conflicts."
313313
# TODO: What do we do now?
314314
fi
315315

316316
# delete branch
317317
if noflag keep; then
318-
git branch -d "$BRANCH"
318+
git_do branch -d "$BRANCH"
319319
fi
320320

321321
if flag push; then
322-
git push "$ORIGIN" "$DEVELOP_BRANCH" || \
322+
git_do push "$ORIGIN" "$DEVELOP_BRANCH" || \
323323
die "Could not push to $DEVELOP_BRANCH from $ORIGIN."
324-
git push "$ORIGIN" "$MASTER_BRANCH" || \
324+
git_do push "$ORIGIN" "$MASTER_BRANCH" || \
325325
die "Could not push to $MASTER_BRANCH from $ORIGIN."
326326
if noflag notag; then
327-
git push --tags "$ORIGIN" || \
327+
git_do push --tags "$ORIGIN" || \
328328
die "Could not push tags to $ORIGIN."
329329
fi
330330
fi

git-flow-init

+14-14
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ cmd_default() {
5353
parse_args "$@"
5454

5555
if ! git rev-parse --git-dir >/dev/null 2>&1; then
56-
git init
56+
git_do init
5757
else
5858
# assure that we are not working in a repo with local changes
5959
git_repo_is_headless || require_clean_working_tree
@@ -121,14 +121,14 @@ cmd_default() {
121121
# name exists, checkout that branch and use it for master
122122
if ! git_local_branch_exists "$master_branch" && \
123123
git_remote_branch_exists "origin/$master_branch"; then
124-
git branch "$master_branch" "origin/$master_branch" >/dev/null 2>&1
124+
git_do branch "$master_branch" "origin/$master_branch" >/dev/null 2>&1
125125
elif ! git_local_branch_exists "$master_branch"; then
126126
die "Local branch '$master_branch' does not exist."
127127
fi
128128
fi
129129

130130
# store the name of the master branch
131-
git config gitflow.branch.master "$master_branch"
131+
git_do config gitflow.branch.master "$master_branch"
132132
fi
133133

134134
# add a develop branch if no such branch exists yet
@@ -185,7 +185,7 @@ cmd_default() {
185185
fi
186186

187187
# store the name of the develop branch
188-
git config gitflow.branch.develop "$develop_branch"
188+
git_do config gitflow.branch.develop "$develop_branch"
189189
fi
190190

191191
# Creation of HEAD
@@ -194,8 +194,8 @@ cmd_default() {
194194
# it to be able to create new branches.
195195
local created_gitflow_branch=0
196196
if ! git rev-parse --quiet --verify HEAD >/dev/null 2>&1; then
197-
git symbolic-ref HEAD "refs/heads/$master_branch"
198-
git commit --allow-empty --quiet -m "Initial commit"
197+
git_do symbolic-ref HEAD "refs/heads/$master_branch"
198+
git_do commit --allow-empty --quiet -m "Initial commit"
199199
created_gitflow_branch=1
200200
fi
201201

@@ -213,9 +213,9 @@ cmd_default() {
213213
# the develop branch now in that case (we base it on master, of course)
214214
if ! git_local_branch_exists "$develop_branch"; then
215215
if git_remote_branch_exists "origin/$develop_branch"; then
216-
git branch "$develop_branch" "origin/$develop_branch" >/dev/null 2>&1
216+
git_do branch "$develop_branch" "origin/$develop_branch" >/dev/null 2>&1
217217
else
218-
git branch --no-track "$develop_branch" "$master_branch"
218+
git_do branch --no-track "$develop_branch" "$master_branch"
219219
fi
220220
created_gitflow_branch=1
221221
fi
@@ -225,7 +225,7 @@ cmd_default() {
225225

226226
# switch to develop branch if its newly created
227227
if [ $created_gitflow_branch -eq 1 ]; then
228-
git checkout -q "$develop_branch"
228+
git_do checkout -q "$develop_branch"
229229
fi
230230

231231
# finally, ask the user for naming conventions (branch and tag prefixes)
@@ -251,7 +251,7 @@ cmd_default() {
251251
printf "\n"
252252
fi
253253
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
254-
git config gitflow.prefix.feature "$prefix"
254+
git_do config gitflow.prefix.feature "$prefix"
255255
fi
256256

257257
# Release branches
@@ -264,7 +264,7 @@ cmd_default() {
264264
printf "\n"
265265
fi
266266
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
267-
git config gitflow.prefix.release "$prefix"
267+
git_do config gitflow.prefix.release "$prefix"
268268
fi
269269

270270

@@ -278,7 +278,7 @@ cmd_default() {
278278
printf "\n"
279279
fi
280280
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
281-
git config gitflow.prefix.hotfix "$prefix"
281+
git_do config gitflow.prefix.hotfix "$prefix"
282282
fi
283283

284284

@@ -292,7 +292,7 @@ cmd_default() {
292292
printf "\n"
293293
fi
294294
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
295-
git config gitflow.prefix.support "$prefix"
295+
git_do config gitflow.prefix.support "$prefix"
296296
fi
297297

298298

@@ -306,7 +306,7 @@ cmd_default() {
306306
printf "\n"
307307
fi
308308
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
309-
git config gitflow.prefix.versiontag "$prefix"
309+
git_do config gitflow.prefix.versiontag "$prefix"
310310
fi
311311

312312

0 commit comments

Comments
 (0)