Skip to content

Commit ef762a6

Browse files
committed
Add confirmation for force push
1 parent 51a2fda commit ef762a6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Support/app/controllers/remote_controller.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
class RemoteController < ApplicationController
66
ALL_REMOTES = "...all remotes..."
7+
FORCE_PUSH_YES = 'Yes, force push'
8+
FORCE_PUSH_NO = 'No, just push normally'
9+
FORCE_PUSH_CANCEL = 'Cancel'
710

811
include SubmoduleHelper::Update
912
include SubmoduleHelper
@@ -81,6 +84,14 @@ def push
8184
output_show_html and return
8285
end
8386

87+
case TextMate::UI.alert(:warning, "Force push this branch?", "Force pushing to #{branch.name} branch will OVERWRITE the remote branch, are you sure you want to continue?", FORCE_PUSH_YES, FORCE_PUSH_NO, FORCE_PUSH_CANCEL)
88+
when FORCE_PUSH_CANCEL
89+
puts '<h1>Push aborted</h1><p>That was a close one!</p>'
90+
output_show_html and return
91+
when FORCE_PUSH_NO
92+
force = false
93+
end if force
94+
8495
title = "Push"
8596
title = "Force "+title if force
8697

0 commit comments

Comments
 (0)