tekkub-fugit 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/Rakefile +19 -0
  2. data/VERSION.yml +3 -3
  3. data/bin/fugit +0 -0
  4. data/lib/fugit/commit_dialog.rb +6 -9
  5. data/lib/fugit/commit_tab.rb +1 -1
  6. data/lib/fugit/create_branch_dialog.rb +65 -0
  7. data/lib/fugit/delete_branch_dialog.rb +1 -1
  8. data/lib/fugit/fetch_dialog.rb +52 -0
  9. data/lib/fugit/history_list.rb +16 -12
  10. data/lib/fugit/history_tab.rb +3 -0
  11. data/lib/fugit/index_list.rb +8 -3
  12. data/lib/fugit/io_get_line.rb +4 -4
  13. data/lib/fugit/logged_dialog.rb +49 -0
  14. data/lib/fugit/main_frame.rb +16 -1
  15. data/lib/fugit/merge_dialog.rb +68 -0
  16. data/lib/fugit/push_dialog.rb +11 -61
  17. data/lib/fugit/revert_commit_dialog.rb +51 -0
  18. data/lib/fugit/run_command_dialog.rb +40 -0
  19. data/lib/fugit/tab_toolbar.rb +145 -0
  20. data/lib/fugit.rb +19 -1
  21. data/lib/grit/API.txt +101 -0
  22. data/lib/grit/History.txt +28 -0
  23. data/lib/grit/PURE_TODO +35 -0
  24. data/lib/grit/README.txt +222 -0
  25. data/lib/grit/Rakefile +54 -0
  26. data/lib/grit/VERSION.yml +4 -0
  27. data/lib/grit/benchmarks.rb +129 -0
  28. data/lib/grit/benchmarks.txt +21 -0
  29. data/lib/grit/examples/ex_add_commit.rb +13 -0
  30. data/lib/grit/examples/ex_index.rb +14 -0
  31. data/lib/grit/grit.gemspec +36 -0
  32. data/lib/grit/lib/grit/actor.rb +36 -0
  33. data/lib/grit/lib/grit/blame.rb +61 -0
  34. data/lib/grit/lib/grit/blob.rb +117 -0
  35. data/lib/grit/lib/grit/commit.rb +238 -0
  36. data/lib/grit/lib/grit/commit_stats.rb +104 -0
  37. data/lib/grit/lib/grit/config.rb +44 -0
  38. data/lib/grit/lib/grit/diff.rb +70 -0
  39. data/lib/grit/lib/grit/errors.rb +7 -0
  40. data/lib/grit/lib/grit/git-ruby/commit_db.rb +52 -0
  41. data/lib/grit/lib/grit/git-ruby/file_index.rb +193 -0
  42. data/lib/grit/lib/grit/git-ruby/git_object.rb +344 -0
  43. data/lib/grit/lib/grit/git-ruby/internal/loose.rb +137 -0
  44. data/lib/grit/lib/grit/git-ruby/internal/mmap.rb +58 -0
  45. data/lib/grit/lib/grit/git-ruby/internal/pack.rb +382 -0
  46. data/lib/grit/lib/grit/git-ruby/internal/raw_object.rb +37 -0
  47. data/lib/grit/lib/grit/git-ruby/object.rb +319 -0
  48. data/lib/grit/lib/grit/git-ruby/repository.rb +736 -0
  49. data/lib/grit/lib/grit/git-ruby.rb +186 -0
  50. data/lib/grit/lib/grit/git.rb +141 -0
  51. data/lib/grit/lib/grit/index.rb +122 -0
  52. data/lib/grit/lib/grit/lazy.rb +33 -0
  53. data/lib/grit/lib/grit/merge.rb +45 -0
  54. data/lib/grit/lib/grit/ref.rb +99 -0
  55. data/lib/grit/lib/grit/repo.rb +441 -0
  56. data/lib/grit/lib/grit/status.rb +151 -0
  57. data/lib/grit/lib/grit/submodule.rb +84 -0
  58. data/lib/grit/lib/grit/tag.rb +66 -0
  59. data/lib/grit/lib/grit/tree.rb +104 -0
  60. data/lib/grit/lib/grit.rb +71 -0
  61. data/lib/grit/lib/open3_detach.rb +46 -0
  62. data/lib/icons/application_go.png +0 -0
  63. data/lib/icons/arrow_divide_add.png +0 -0
  64. data/lib/icons/arrow_refresh.png +0 -0
  65. data/lib/icons/cross.png +0 -0
  66. metadata +56 -10
  67. data/fugit.gemspec +0 -32
  68. data/lib/fugit/commit_tab_toolbar.rb +0 -111
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |s|
6
+ s.name = "fugit"
7
+ s.email = "tekkub@gmail.com"
8
+ s.homepage = "http://github.com/tekkub/fugit"
9
+ s.description = "A cross-platform replacement for git-gui based on wxruby"
10
+ s.summary = s.description
11
+ s.authors = ["Tekkub"]
12
+ s.bindir = 'bin'
13
+ s.add_dependency('wxruby', [">= 1.9.9"])
14
+ end
15
+ rescue LoadError
16
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
17
+ end
18
+
19
+ task :default => :gemspec
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
- ---
2
- :minor: 0
3
- :patch: 5
1
+ ---
4
2
  :major: 0
3
+ :minor: 0
4
+ :patch: 6
data/bin/fugit CHANGED
File without changes
@@ -40,10 +40,9 @@ module Fugit
40
40
  end
41
41
 
42
42
  def show_modal
43
- name = `git config user.name`
44
- email = `git config user.email`
45
- @committer.set_value("#{name.chomp} <#{email.chomp}>")
46
- @author.set_value("#{name.chomp} <#{email.chomp}>")
43
+ user = "#{repo.config["user.name"]} <#{repo.config["user.email"]}>"
44
+ @committer.set_value(user)
45
+ @author.set_value(user)
47
46
  @input.set_value("")
48
47
  @amend_check.set_value(false)
49
48
  @input.set_focus
@@ -68,11 +67,9 @@ module Fugit
68
67
  @no_msg_error ||= MessageDialog.new(self, "Please enter a commit message.", "Commit error", OK|ICON_ERROR)
69
68
  @no_msg_error.show_modal
70
69
  else
71
- commit_file = File.join(Dir.pwd, ".git", "fugit_commit.txt")
72
- File.open(commit_file, "w") {|f| f << msg}
73
- amend = @amend_check.is_checked ? "--amend " : ""
74
- `git commit #{amend}--file=.git/fugit_commit.txt --author="#{@author.get_value}"`
75
- File.delete(commit_file)
70
+ vals = {:author => %Q|"#{@author.get_value}"|}
71
+ vals[:amend] = true if @amend_check.is_checked
72
+ repo.git.commit(vals, '-m', msg.gsub('"', '\"'))
76
73
  end_modal ID_OK
77
74
  end
78
75
  end
@@ -10,7 +10,7 @@ module Fugit
10
10
  @vsplitter.set_minimum_pane_size(150)
11
11
 
12
12
 
13
- @toolbar = CommitTabToolbar.new(self)
13
+ @toolbar = TabToolbar.new(self)
14
14
  @diff = Diff.new(@vsplitter)
15
15
 
16
16
  @index = IndexList.new(@vsplitter)
@@ -0,0 +1,65 @@
1
+ include Wx
2
+
3
+ module Fugit
4
+ class CreateBranchDialog < Dialog
5
+ def initialize(parent)
6
+ super(parent, ID_ANY, "Create branch", :size => Size.new(300, 165))
7
+
8
+ @name = TextCtrl.new(self, ID_ANY)
9
+ @refs = ComboBox.new(self, ID_ANY)
10
+
11
+ @force_check = CheckBox.new(self, ID_ANY)
12
+ @force_check.set_label("&Force")
13
+ @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.")
14
+
15
+ butt_sizer = create_button_sizer(OK|CANCEL)
16
+ butt_sizer.get_children.map {|s| s.get_window}.compact.each {|b| b.set_label("Create") if b.get_label == "OK"}
17
+ evt_button(get_affirmative_id, :on_ok)
18
+
19
+ box = BoxSizer.new(VERTICAL)
20
+ box.add(StaticText.new(self, ID_ANY, "New branch name:"), 0, EXPAND|ALL, 4)
21
+ box.add(@name, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
22
+ box.add(StaticText.new(self, ID_ANY, "Create at:"), 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
23
+ box.add(@refs, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
24
+ box.add(@force_check, 1, EXPAND|LEFT|RIGHT|BOTTOM, 4)
25
+ box.add(butt_sizer, 0, EXPAND|BOTTOM, 4)
26
+
27
+ self.set_sizer(box)
28
+ end
29
+
30
+ def show(ref = "HEAD")
31
+ branches = `git branch -a`
32
+ branches = ["HEAD"] + branches.split("\n").map {|b| b[2..-1]}
33
+ @refs.clear
34
+ branches.each {|b| @refs.append(b)}
35
+ @refs.set_value(ref)
36
+ @name.set_value("")
37
+ @force_check.set_value(false)
38
+
39
+ super()
40
+ @name.set_focus
41
+ end
42
+
43
+ def on_ok
44
+ force = @force_check.is_checked ? "-f " : ""
45
+ name = @name.get_value
46
+ ref = @refs.get_value
47
+
48
+ if name.strip.empty?
49
+ @no_name_dialog ||= MessageDialog.new(self, "Cannot create branch without a name.", "No branch name", ICON_EXCLAMATION)
50
+ @no_name_dialog.show_modal
51
+ return
52
+ end
53
+
54
+ err = `git branch #{force}#{name} #{ref} 2>&1`
55
+
56
+ if err.empty?
57
+ send_message(:branch_created)
58
+ end_modal(ID_OK)
59
+ else
60
+ MessageDialog.new(self, err, "Error creating branch", OK|ICON_ERROR).show_modal
61
+ end
62
+ end
63
+
64
+ end
65
+ end
@@ -34,7 +34,7 @@ module Fugit
34
34
  branches = @branch_list.get_checked_items.map {|i| @branch_list.get_string(i)}
35
35
  unless (unmerged_to_delete = branches.reject {|b| !unmerged.include?(b)}).empty?
36
36
  dialog = MessageDialog.new(self, "These branches are not merged into the current HEAD:\n #{unmerged_to_delete.join("\n ")}\n\nDeleting them may cause data loss, continue?",
37
- "Unmerged branches", YES_NO|NO_DEFAULT|ICON_EXCLAMATION)
37
+ "Unmerged branches", YES_NO|ICON_EXCLAMATION)
38
38
  return if dialog.show_modal != ID_YES
39
39
  end
40
40
  `git branch -D #{branches.join(" ")} 2>&1`
@@ -0,0 +1,52 @@
1
+ include Wx
2
+
3
+ module Fugit
4
+ class FetchDialog < Dialog
5
+ def initialize(parent)
6
+ super(parent, ID_ANY, "Fetch remotes", :size => Size.new(250, 300))
7
+
8
+ @remotes = CheckListBox.new(self, ID_ANY)
9
+ @tag_check = CheckBox.new(self, ID_ANY)
10
+ @tag_check.set_label("Include &tags")
11
+ @prune_check = CheckBox.new(self, ID_ANY)
12
+ @prune_check.set_label("&Prune deleted branches")
13
+
14
+ butt_sizer = create_button_sizer(OK|CANCEL)
15
+ butt_sizer.get_children.map {|s| s.get_window}.compact.each {|b| b.set_label(b.get_label == "OK" ? "Fetch" : "Close")}
16
+ evt_button(get_affirmative_id, :on_ok)
17
+
18
+ box = BoxSizer.new(VERTICAL)
19
+ box.add(StaticText.new(self, ID_ANY, "Fetch from:"), 0, EXPAND|ALL, 4)
20
+ box.add(@remotes, 1, EXPAND|LEFT|RIGHT|BOTTOM, 4)
21
+ box.add(@tag_check, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
22
+ box.add(@prune_check, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
23
+ box.add(butt_sizer, 0, EXPAND|BOTTOM, 4)
24
+
25
+ self.set_sizer(box)
26
+ end
27
+
28
+ def show
29
+ remotes = `git remote`
30
+ remotes = remotes.split("\n")
31
+ @remotes.set(remotes)
32
+ @remotes.check(@remotes.find_string("origin")) if remotes.include?("origin")
33
+ @tag_check.set_value(true)
34
+ @prune_check.set_value(false)
35
+
36
+ super
37
+ end
38
+
39
+ def on_ok
40
+ remotes = @remotes.get_checked_items.map {|i| @remotes.get_string(i)}
41
+ tags = @tag_check.is_checked ? "" : "--no-tags "
42
+
43
+ self.end_modal(ID_OK)
44
+
45
+ @log_dialog ||= LoggedDialog.new(self, "Fetching remotes")
46
+ @log_dialog.show
47
+ remotes.each {|remote| @log_dialog.run_command("git fetch #{tags}#{remote}", remote == remotes.last && !@prune_check.is_checked)}
48
+ remotes.each {|remote| @log_dialog.run_command("git remote prune #{remote}", remote == remotes.last)} if @prune_check.is_checked
49
+ end
50
+
51
+ end
52
+ end
@@ -13,7 +13,7 @@ module Fugit
13
13
 
14
14
  @list_menu = Menu.new
15
15
  @menu_create_branch = MenuItem.new(@list_menu, ID_ANY, 'Create new branch here')
16
- @menu_create_branch.set_bitmap(get_icon("arrow_divide.png"))
16
+ @menu_create_branch.set_bitmap(get_icon("arrow_divide_add.png"))
17
17
  @list_menu.append_item(@menu_create_branch)
18
18
  evt_menu(@menu_create_branch, :on_menu_create_branch)
19
19
 
@@ -24,6 +24,11 @@ module Fugit
24
24
 
25
25
  @list_menu.append_separator
26
26
 
27
+ @menu_revert_commit = MenuItem.new(@list_menu, ID_ANY, 'Revert this commit')
28
+ @menu_revert_commit.set_bitmap(get_icon("cross.png"))
29
+ @list_menu.append_item(@menu_revert_commit)
30
+ evt_menu(@menu_revert_commit, :on_menu_revert_commit)
31
+
27
32
  @menu_soft_reset = @list_menu.append('Soft-reset branch to here')
28
33
  evt_menu(@menu_soft_reset, :on_menu_soft_reset)
29
34
 
@@ -43,6 +48,8 @@ module Fugit
43
48
 
44
49
  register_for_message(:history_tab_shown, :update_list)
45
50
  register_for_message(:tab_switch, :update_list)
51
+ register_for_message(:branch_created, :update_list)
52
+ register_for_message(:branch_deleted, :update_list)
46
53
  register_for_message(:refresh, :update_list)
47
54
  register_for_message(:exiting) {self.hide} # Things seem to run smoother if we hide before destruction
48
55
  end
@@ -98,16 +105,8 @@ module Fugit
98
105
  end
99
106
 
100
107
  def on_menu_create_branch(event)
101
- @new_branch_dialog ||= TextEntryDialog.new(self, "New branch name:", "Create branch")
102
- @new_branch_dialog.set_value("")
103
- if @new_branch_dialog.show_modal == ID_OK
104
- err = `git branch #{@new_branch_dialog.get_value} #{@menu_data} 2>&1`
105
- if err.empty?
106
- send_message(:refresh)
107
- else
108
- MessageDialog.new(self, err, "Error creating branch", OK|ICON_ERROR).show_modal
109
- end
110
- end
108
+ @new_branch_dialog ||= CreateBranchDialog.new(self)
109
+ @new_branch_dialog.show(@menu_data)
111
110
  end
112
111
 
113
112
  def on_menu_cherry_pick(event)
@@ -119,6 +118,11 @@ module Fugit
119
118
  end
120
119
  end
121
120
 
121
+ def on_menu_revert_commit(event)
122
+ @revert_commit_dialog ||= RevertCommitDialog.new(self)
123
+ @revert_commit_dialog.show(@menu_data)
124
+ end
125
+
122
126
  def on_menu_soft_reset(event)
123
127
  err = `git reset --soft #{@menu_data} 2>&1`
124
128
  if !err.empty?
@@ -139,7 +143,7 @@ module Fugit
139
143
 
140
144
  def on_menu_hard_reset(event)
141
145
  if has_uncomitted_changes?
142
- @uncomitted_hard_dialog ||= MessageDialog.new(self, "Uncommitted changes will be lost, continue?", "Uncomitted changes", YES_NO|NO_DEFAULT|ICON_EXCLAMATION)
146
+ @uncomitted_hard_dialog ||= MessageDialog.new(self, "Uncommitted changes will be lost, continue?", "Uncomitted changes", YES_NO|ICON_EXCLAMATION)
143
147
  return if @uncomitted_hard_dialog.show_modal != ID_YES
144
148
  end
145
149
 
@@ -7,8 +7,11 @@ module Fugit
7
7
  super
8
8
 
9
9
  @history_list = HistoryList.new(self)
10
+ @toolbar = TabToolbar.new(self, false)
10
11
 
11
12
  box = BoxSizer.new(VERTICAL)
13
+ box.add(@toolbar, 0, EXPAND)
14
+ box.add_spacer(3)
12
15
  box.add(@history_list, 1, EXPAND)
13
16
  self.set_sizer(box)
14
17
  end
@@ -46,6 +46,7 @@ module Fugit
46
46
  register_for_message(:branch_checkout) {update_tree if is_shown_on_screen}
47
47
  register_for_message(:commit_saved, :update_tree)
48
48
  register_for_message(:index_changed, :update_tree)
49
+ register_for_message(:tab_switch, :update_tree)
49
50
  register_for_message(:exiting) {self.hide} # Things seem to run smoother if we hide before destruction
50
51
 
51
52
  update_tree
@@ -138,8 +139,12 @@ module Fugit
138
139
  when :unstaged
139
140
  case change
140
141
  when :new
141
- val = File.read(file)
142
- send_message(:diff_raw, val)
142
+ if File.directory?(file)
143
+ send_message(:diff_raw, "Git repo\n\nNote that staging with fugit will stage the files inside the repo,\nit will *not* add a git-submodule.")
144
+ else
145
+ val = File.read(file)
146
+ send_message(:diff_raw, val)
147
+ end
143
148
  when :modified, :deleted
144
149
  val = `git diff -- "#{file}"`
145
150
  send_message(:diff_set, val, :unstaged)
@@ -167,7 +172,7 @@ module Fugit
167
172
  end
168
173
 
169
174
  def on_menu_revert_changes(event)
170
- @confirm_revert ||= MessageDialog.new(self, "Are you sure you want to revert these changes?\nThe changes will be lost, this cannot be undone.", "Confirm revert", NO_DEFAULT|YES_NO|ICON_EXCLAMATION)
175
+ @confirm_revert ||= MessageDialog.new(self, "Are you sure you want to revert these changes?\nThe changes will be lost, this cannot be undone.", "Confirm revert", YES_NO|ICON_EXCLAMATION)
171
176
 
172
177
  if @confirm_revert.show_modal == ID_YES
173
178
  diff = `git diff -- "#{@menu_data[0]}"`
@@ -2,12 +2,12 @@
2
2
  class IO
3
3
  def get_line
4
4
  line = nil
5
+ ending = nil
5
6
  while c = self.read(1)
7
+ line ||= ""
8
+ line << c
6
9
  if c == "\r" || c == "\n"
7
- break if line
8
- else
9
- line ||= ""
10
- line << c
10
+ break
11
11
  end
12
12
  end
13
13
  line
@@ -0,0 +1,49 @@
1
+ include Wx
2
+
3
+ module Fugit
4
+ class LoggedDialog < Dialog
5
+ def initialize(parent, title)
6
+ super(parent, ID_ANY, title, :size => Size.new(600, 300))
7
+
8
+ @log = TextCtrl.new(self, ID_ANY, :size => Size.new(20, 150), :style => TE_MULTILINE|TE_DONTWRAP|TE_READONLY)
9
+ @current_line = StaticText.new(self, ID_ANY, "")
10
+ @progress = Gauge.new(self, ID_ANY, 100, :size => Size.new(20, 20))
11
+
12
+ box = BoxSizer.new(VERTICAL)
13
+ box.add(@log, 1, EXPAND|TOP|LEFT|RIGHT, 4)
14
+ box.add(@current_line, 0, EXPAND|ALL, 4)
15
+ box.add(@progress, 0, EXPAND|ALL, 4)
16
+ self.set_sizer(box)
17
+ end
18
+
19
+ def show()
20
+ @progress.set_value(0)
21
+ @log.clear
22
+ super
23
+ end
24
+
25
+ def run_command(command, close_on_success = true)
26
+ @progress.pulse
27
+ @log.append_text("#{@log.get_last_position == 0 ? "" : "\n"}> #{command}\n")
28
+
29
+ ret = IO.popen("#{command} 2>&1") do |io|
30
+ last_cr = true
31
+ while (line = io.get_line)
32
+ @log.append_text(@current_line.get_label) unless last_cr
33
+ @current_line.set_label(line)
34
+ @progress.pulse
35
+ last_cr = (line[-1..-1] == "\r")
36
+ end
37
+ end
38
+ @progress.set_value(0)
39
+ @log.append_text(@current_line.get_label)
40
+ @current_line.set_label("")
41
+ if $?.success? && close_on_success
42
+ send_message(:refresh)
43
+ @current_line.set_label("This window will close in 5 seconds")
44
+ Timer.after(5000) {self.end_modal(ID_OK)}
45
+ end
46
+ end
47
+
48
+ end
49
+ end
@@ -1,6 +1,19 @@
1
1
  include Wx
2
2
  include IconLoader
3
3
 
4
+ module Wx
5
+ class EvtHandler
6
+ def repo
7
+ @@repo
8
+ end
9
+
10
+ def repo=(val)
11
+ @@repo = val
12
+ end
13
+ end
14
+ end
15
+
16
+
4
17
  module Fugit
5
18
  class MainFrame < Frame
6
19
  def initialize(title, version)
@@ -9,6 +22,8 @@ module Fugit
9
22
 
10
23
  @app_verion = version
11
24
 
25
+ self.repo = Grit::Repo.new(Dir.pwd)
26
+
12
27
  @notebook = Notebook.new(self, ID_ANY, :style => FULL_REPAINT_ON_RESIZE)
13
28
  @commit_panel = CommitTab.new(@notebook)
14
29
  @history_panel = HistroyTab.new(@notebook)
@@ -33,7 +48,7 @@ module Fugit
33
48
  # Using ID_EXIT standard id means the menu item will be given the right label for the platform and language, and placed in the correct platform-specific menu - eg on OS X, in the Application's menu
34
49
  menu_file.append(ID_SAVE, "&Save commit\tCtrl-S", "Save commit")
35
50
  push = menu_file.append(ID_ANY, "&Push\tCtrl-P", "Push commits to a remote repo")
36
- refresh = menu_file.append(ID_ANY, "&Refresh\tF5", "Refresh the index list")
51
+ refresh = menu_file.append(ID_ANY, "&Refresh\tCtrl-R", "Refresh the index list")
37
52
  menu_file.append(ID_EXIT, "E&xit", "Quit this program")
38
53
  menu_bar.append(menu_file, "&File")
39
54
 
@@ -0,0 +1,68 @@
1
+ include Wx
2
+
3
+ module Fugit
4
+ class MergeDialog < Dialog
5
+ def initialize(parent)
6
+ super(parent, ID_ANY, "Merge branches", :size => Size.new(250, 300))
7
+
8
+ @branch_list = CheckListBox.new(self, ID_ANY)
9
+ @log_check = CheckBox.new(self, ID_ANY)
10
+ @log_check.set_label("Include commit &log")
11
+ @log_check.set_tool_tip("Adds a log of commit summaries to the merge commit's message")
12
+ @commit_check = CheckBox.new(self, ID_ANY)
13
+ @commit_check.set_label("&Commit result")
14
+ @commit_check.set_tool_tip("If there are no merge conficts, commit the results automatically.")
15
+ @squash_check = CheckBox.new(self, ID_ANY)
16
+ @squash_check.set_label("&Squash result")
17
+ @squash_check.set_tool_tip("Instead of creating a merge commit, squash all of\nthe changes together and stage them for commit.\nThis will create the same changeset a normal\nmerge would, without creating a merge commit.")
18
+ @noff_check = CheckBox.new(self, ID_ANY)
19
+ @noff_check.set_label("&Fast-forward when possible")
20
+ @noff_check.set_tool_tip("Do not generate a merge commit if the merge resolved as a fast-forward, only update the branch pointer.")
21
+
22
+ butt_sizer = create_button_sizer(OK|CANCEL)
23
+ butt_sizer.get_children.map {|s| s.get_window}.compact.each {|b| b.set_label("Merge") if b.get_label == "OK"}
24
+ evt_button(get_affirmative_id, :on_ok)
25
+
26
+ box = BoxSizer.new(VERTICAL)
27
+ box.add(StaticText.new(self, ID_ANY, "Select branches:"), 0, EXPAND|ALL, 4)
28
+ box.add(@branch_list, 1, EXPAND|LEFT|RIGHT|BOTTOM, 4)
29
+ box.add(@log_check, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
30
+ box.add(@commit_check, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
31
+ box.add(@squash_check, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
32
+ box.add(@noff_check, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
33
+ box.add(butt_sizer, 0, EXPAND|BOTTOM, 4)
34
+
35
+ self.set_sizer(box)
36
+ end
37
+
38
+ def show
39
+ branches = `git branch -a --no-merged`
40
+ branches = branches.split("\n").map {|b| b.strip}
41
+ @branch_list.set(branches)
42
+
43
+ @log_check.set_value(false)
44
+ @commit_check.set_value(true)
45
+ @squash_check.set_value(false)
46
+ @noff_check.set_value(true)
47
+
48
+ super
49
+ end
50
+
51
+ def on_ok
52
+ branches = @branch_list.get_checked_items.map {|i| @branch_list.get_string(i)}
53
+ args = []
54
+ args << "--log" if @log_check.is_checked
55
+ args << "--no-commit" unless @commit_check.is_checked || @squash_check.is_checked
56
+ args << "--squash" if @squash_check.is_checked
57
+ args << "--no-ff" unless @noff_check.is_checked
58
+ command = "git merge #{args.empty? ? "" : "#{args.join(" ")} "}#{branches.join(" ")}"
59
+
60
+ self.end_modal(ID_OK)
61
+
62
+ @log_dialog ||= LoggedDialog.new(self, "Merging branches")
63
+ @log_dialog.show
64
+ @log_dialog.run_command(command)
65
+ end
66
+
67
+ end
68
+ end
@@ -3,7 +3,7 @@ include Wx
3
3
  module Fugit
4
4
  class PushDialog < Dialog
5
5
  def initialize(parent)
6
- super(parent, ID_ANY, "Push branches", :size => Size.new(400, 500))
6
+ super(parent, ID_ANY, "Push branches", :size => Size.new(250, 300))
7
7
 
8
8
  @branch_list = CheckListBox.new(self, ID_ANY)
9
9
  @tag_check = CheckBox.new(self, ID_ANY)
@@ -11,30 +11,18 @@ module Fugit
11
11
  @force_check = CheckBox.new(self, ID_ANY)
12
12
  @force_check.set_label("&Force update")
13
13
  @remote = ComboBox.new(self, ID_ANY)
14
- @log = TextCtrl.new(self, ID_ANY, :size => Size.new(20, 150), :style => TE_MULTILINE|TE_DONTWRAP|TE_READONLY)
15
- @progress = Gauge.new(self, ID_ANY, 100, :size => Size.new(20, 20))
16
14
 
17
15
  butt_sizer = create_button_sizer(OK|CANCEL)
18
16
  butt_sizer.get_children.map {|s| s.get_window}.compact.each {|b| b.set_label(b.get_label == "OK" ? "Push" : "Close")}
19
17
  evt_button(get_affirmative_id, :on_ok)
20
18
 
21
19
  box = BoxSizer.new(VERTICAL)
22
- box2 = BoxSizer.new(HORIZONTAL)
23
- box3 = BoxSizer.new(VERTICAL)
24
-
25
- box3.add(@tag_check, 1)
26
- box3.add(@force_check, 1, TOP, 4)
27
-
28
- box2.add(@branch_list, 1, EXPAND|LEFT|RIGHT|BOTTOM, 4)
29
- box2.add(box3, 1, ALL, 4)
30
-
31
- box.add(StaticText.new(self, ID_ANY, "Select branches:"), 0, EXPAND|ALL, 4)
32
- box.add(box2, 1, EXPAND)
33
20
  box.add(StaticText.new(self, ID_ANY, "Push to:"), 0, EXPAND|ALL, 4)
34
21
  box.add(@remote, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
35
- box.add(StaticText.new(self, ID_ANY, "Output:"), 0, EXPAND|ALL, 4)
36
- box.add(@log, 0, EXPAND|LEFT|RIGHT, 4)
37
- box.add(@progress, 0, EXPAND|ALL, 4)
22
+ box.add(StaticText.new(self, ID_ANY, "Select branches:"), 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
23
+ box.add(@branch_list, 1, EXPAND|LEFT|RIGHT|BOTTOM, 4)
24
+ box.add(@tag_check, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
25
+ box.add(@force_check, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
38
26
  box.add(butt_sizer, 0, EXPAND|BOTTOM, 4)
39
27
 
40
28
  self.set_sizer(box)
@@ -51,62 +39,24 @@ module Fugit
51
39
  branches = branches.split("\n").map {|b| b.split(" ").last}
52
40
  @branch_list.set(branches)
53
41
  @branch_list.check(@branch_list.find_string(current)) if current
54
-
55
- @progress.set_value(0)
56
- @log.clear
42
+ @tag_check.set_value(false)
43
+ @force_check.set_value(false)
57
44
 
58
45
  super
59
46
  end
60
47
 
61
48
  def on_ok
62
- @progress.set_value(0)
63
- failed = false
64
- last_line_type = nil
65
-
66
49
  branches = @branch_list.get_checked_items.map {|i| @branch_list.get_string(i)}
67
50
  tags = @tag_check.is_checked ? "--tags " : ""
68
51
  force = @force_check.is_checked ? "--force " : ""
69
52
  remote = @remote.get_value
70
53
  command = "git push #{tags}#{force}#{remote} #{branches.join(" ")}"
71
- @log.append_text("#{@log.get_last_position == 0 ? "" : "\n\n"}> #{command}")
72
-
73
- IO.popen("#{command} 2>&1") do |io|
74
- while line = io.get_line
75
- last_line_type = case line
76
- when "Everything up-to-date"
77
- @progress.set_value(100)
78
- update_log(last_line_type, nil, line)
79
- when /Counting objects: \d+, done./
80
- @progress.set_value(10)
81
- update_log(last_line_type, :counting, line)
82
- when /Counting objects: \d+/
83
- update_log(last_line_type, :counting, line)
84
- when /Compressing objects:\s+\d+% \((\d+)\/(\d+)\)/
85
- @progress.set_value(10 + (45*$1.to_f/$2.to_f).to_i)
86
- update_log(last_line_type, :compressing, line)
87
- when /Writing objects:\s+\d+% \((\d+)\/(\d+)\)/
88
- @progress.set_value(55 + (45*$1.to_f/$2.to_f).to_i)
89
- update_log(last_line_type, :writing, line)
90
- when /\[rejected\]/
91
- failed = true
92
- @progress.set_value(100)
93
- update_log(last_line_type, nil, line)
94
- else
95
- update_log(last_line_type, nil, line)
96
- end
97
- end
98
- end
99
54
 
100
- #~ end_modal(ID_OK) if success
101
- end
55
+ end_modal(ID_OK)
102
56
 
103
- def update_log(last, current, line)
104
- if last == current && !last.nil?
105
- @log.replace(@log.xy_to_position(0, @log.get_number_of_lines - 1), @log.get_last_position, line)
106
- else
107
- @log.append_text("\n" + line)
108
- end
109
- current
57
+ @log_dialog ||= LoggedDialog.new(self, "Pushing branches")
58
+ @log_dialog.show
59
+ @log_dialog.run_command(command)
110
60
  end
111
61
 
112
62
  end
@@ -0,0 +1,51 @@
1
+ include Wx
2
+
3
+ module Fugit
4
+ class RevertCommitDialog < Dialog
5
+ def initialize(parent)
6
+ super(parent, ID_ANY, "Revert commit", :size => Size.new(300, 120))
7
+
8
+ @name = TextCtrl.new(self, ID_ANY)
9
+
10
+ @commit_check = CheckBox.new(self, ID_ANY)
11
+ @commit_check.set_label("&Commit")
12
+ @commit_check.set_tool_tip("Commit the results of the revert")
13
+
14
+ butt_sizer = create_button_sizer(OK|CANCEL)
15
+ butt_sizer.get_children.map {|s| s.get_window}.compact.each {|b| b.set_label("Create") if b.get_label == "OK"}
16
+ evt_button(get_affirmative_id, :on_ok)
17
+
18
+ box = BoxSizer.new(VERTICAL)
19
+ box.add(StaticText.new(self, ID_ANY, "Ref:"), 0, EXPAND|ALL, 4)
20
+ box.add(@name, 0, EXPAND|LEFT|RIGHT|BOTTOM, 4)
21
+ box.add(@commit_check, 1, EXPAND|LEFT|RIGHT|BOTTOM, 4)
22
+ box.add(butt_sizer, 0, EXPAND|BOTTOM, 4)
23
+
24
+ self.set_sizer(box)
25
+ end
26
+
27
+ def show(ref = "HEAD")
28
+ @name.set_value(ref)
29
+ @commit_check.set_value(true)
30
+
31
+ super()
32
+ @name.set_focus
33
+ end
34
+
35
+ def on_ok
36
+ ref = @name.get_value
37
+
38
+ opts = {:no_edit => true}
39
+ opts[:no_commit] = true unless @commit_check.is_checked
40
+ repo.git.revert(opts, ref)
41
+
42
+ if repo.git.last_status.success?
43
+ send_message(:commit_saved)
44
+ end_modal(ID_OK)
45
+ else
46
+ MessageDialog.new(self, repo.git.last_err, "Error reverting commit", OK|ICON_ERROR).show_modal
47
+ end
48
+ end
49
+
50
+ end
51
+ end