Skip to content

Commit 8b3ee8e

Browse files
stcharMatthias Putz
authored and
Matthias Putz
committed
Extension: added force option to push command, thanks to headcrabmeat
1 parent 1257d23 commit 8b3ee8e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

subcmds/push.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ def _Options(self, p):
8484
type='string', action='store', dest='dest_branch',
8585
metavar='BRANCH',
8686
help='Push on this target branch.')
87+
p.add_option('-f', '--force',
88+
dest='force_push',
89+
action='store_true',
90+
help='Force push')
8791

8892
# Options relating to push hook. Note that verify and no-verify are NOT
8993
# opposites of each other, which is why they store to different locations.
@@ -252,7 +256,7 @@ def _Push(self, opt, todo):
252256
branch.uploaded = False
253257
continue
254258

255-
self.Push(branch, dest_branch=destination)
259+
self.Push(branch, dest_branch=destination, force=opt.force_push)
256260
branch.uploaded = True
257261
except UploadError as e:
258262
branch.error = e
@@ -287,7 +291,7 @@ def _Push(self, opt, todo):
287291
sys.exit(1)
288292

289293
def Push(self, branch_base, branch=None,
290-
dest_branch=None):
294+
dest_branch=None, force=False):
291295
"""Pushs the named branch.
292296
"""
293297
project = branch_base.project
@@ -313,6 +317,10 @@ def Push(self, branch_base, branch=None,
313317

314318
remote = branch.remote.name
315319
cmd = ['push']
320+
321+
if force:
322+
cmd.append('--force')
323+
316324
cmd.append(remote)
317325

318326
if dest_branch.startswith(R_HEADS):

0 commit comments

Comments
 (0)