Class: Fugit::RevertCommitDialog

Inherits:
Dialog
  • Object
show all
Defined in:
lib/fugit/revert_commit_dialog.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ RevertCommitDialog

Returns a new instance of RevertCommitDialog.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fugit/revert_commit_dialog.rb', line 5

def initialize(parent)
	super(parent, ID_ANY, "Revert commit", :size => Size.new(300, 120))

	@name = TextCtrl.new(self, ID_ANY)

	@commit_check = CheckBox.new(self, ID_ANY)
	@commit_check.set_label("&Commit")
	@commit_check.set_tool_tip("Commit the results of the revert")

	butt_sizer = create_button_sizer(OK|CANCEL)
	butt_sizer.get_children.map {|s| s.get_window}.compact.each {|b| b.set_label("Create") if b.get_label == "OK"}
	evt_button(get_affirmative_id, :on_ok)

	box = BoxSizer.new(VERTICAL)
	box.add(StaticText.new(self, ID_ANY, "Ref:"), 0, EXPAND|ALL, 4)
	box.add(@name, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
	box.add(@commit_check, 1, EXPAND|LEFT|RIGHT|BOTTOM, 4)
	box.add(butt_sizer, 0, EXPAND|BOTTOM, 4)

	self.set_sizer(box)
end

Instance Method Details

#on_okObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fugit/revert_commit_dialog.rb', line 35

def on_ok
	ref = @name.get_value

	opts = {:no_edit => true}
	opts[:no_commit] = true unless @commit_check.is_checked
	repo.git.revert(opts, ref)

	if repo.git.last_status.success?
		send_message(:commit_saved)
		end_modal(ID_OK)
	else
		MessageDialog.new(self, repo.git.last_err, "Error reverting commit", OK|ICON_ERROR).show_modal
	end
end

#show(ref = "HEAD") ⇒ Object



27
28
29
30
31
32
33
# File 'lib/fugit/revert_commit_dialog.rb', line 27

def show(ref = "HEAD")
	@name.set_value(ref)
	@commit_check.set_value(true)

	super()
	@name.set_focus
end