Sha256: 8562a65e13ea325f4d741c8e6b154e9f37efc719978fbae15ed3e21527357471
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
include Wx module Fugit class CreateBranchDialog < Dialog def initialize(parent) super(parent, ID_ANY, "Create branch", :size => Size.new(300, 165)) @name = TextCtrl.new(self, ID_ANY) @refs = ComboBox.new(self, ID_ANY) @force_check = CheckBox.new(self, ID_ANY) @force_check.set_label("&Force") @force_check.set_tool_tip("Force the creation of a new branch even if it means deleting\na branch that already exists with the same name.") 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, "New branch name:"), 0, EXPAND|ALL, 4) box.add(@name, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4) box.add(StaticText.new(self, ID_ANY, "Create at:"), 0, EXPAND|LEFT|RIGHT|BOTTOM, 4) box.add(@refs, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4) box.add(@force_check, 1, EXPAND|LEFT|RIGHT|BOTTOM, 4) box.add(butt_sizer, 0, EXPAND|BOTTOM, 4) self.set_sizer(box) end def show(ref = "HEAD") branches = `git branch -a` branches = ["HEAD"] + branches.split("\n").map {|b| b[2..-1]} @refs.clear branches.each {|b| @refs.append(b)} @refs.set_value(ref) @name.set_value("") @force_check.set_value(false) super() @name.set_focus end def on_ok force = @force_check.is_checked ? "-f " : "" name = @name.get_value ref = @refs.get_value if name.strip.empty? @no_name_dialog ||= MessageDialog.new(self, "Cannot create branch without a name.", "No branch name", ICON_EXCLAMATION) @no_name_dialog.show_modal return end err = `git branch #{force}#{name} #{ref} 2>&1` if err.empty? send_message(:branch_created) end_modal(ID_OK) else MessageDialog.new(self, err, "Error creating branch", OK|ICON_ERROR).show_modal end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tekkub-fugit-0.0.6 | lib/fugit/create_branch_dialog.rb |