tekkub-fugit 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/fugit.gemspec +3 -3
- data/lib/fugit.rb +4 -0
- data/lib/fugit/commit.rb +6 -1
- data/lib/fugit/commit_tab.rb +30 -0
- data/lib/fugit/diff.rb +35 -8
- data/lib/fugit/graph_renderer.rb +94 -0
- data/lib/fugit/history_list.rb +55 -0
- data/lib/fugit/history_tab.rb +16 -0
- data/lib/fugit/index_list.rb +63 -22
- data/lib/fugit/main_frame.rb +16 -47
- metadata +7 -2
data/VERSION.yml
CHANGED
data/fugit.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{fugit}
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.3"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Tekkub"]
|
7
|
-
s.date = %q{2009-02-
|
7
|
+
s.date = %q{2009-02-17}
|
8
8
|
s.default_executable = %q{fugit}
|
9
9
|
s.description = %q{A cross-platform replacement for git-gui based on wxruby}
|
10
10
|
s.email = %q{tekkub@gmail.com}
|
11
11
|
s.executables = ["fugit"]
|
12
|
-
s.files = ["fugit.gemspec", "SciTE.properties", "VERSION.yml", "bin/fugit", "lib/fugit", "lib/fugit/commit.rb", "lib/fugit/console.rb", "lib/fugit/diff.rb", "lib/fugit/icon_loader.rb", "lib/fugit/index_list.rb", "lib/fugit/main_frame.rb", "lib/fugit/messages.rb", "lib/fugit/SciTE.properties", "lib/fugit.rb", "lib/icons", "lib/icons/asterisk_yellow.png", "lib/icons/disk.png", "lib/icons/folder_add.png", "lib/icons/folder_delete.png", "lib/icons/page_add.png", "lib/icons/page_delete.png", "lib/icons/page_down.gif", "lib/icons/page_up.gif", "lib/icons/plus_minus.gif", "lib/icons/script.png", "lib/icons/script_add.png", "lib/icons/script_delete.png", "lib/icons/script_edit.png", "lib/icons/text_signature.png", "lib/icons/tick.png"]
|
12
|
+
s.files = ["fugit.gemspec", "SciTE.properties", "VERSION.yml", "bin/fugit", "lib/fugit", "lib/fugit/commit.rb", "lib/fugit/commit_tab.rb", "lib/fugit/console.rb", "lib/fugit/diff.rb", "lib/fugit/graph_renderer.rb", "lib/fugit/history_list.rb", "lib/fugit/history_tab.rb", "lib/fugit/icon_loader.rb", "lib/fugit/index_list.rb", "lib/fugit/main_frame.rb", "lib/fugit/messages.rb", "lib/fugit/SciTE.properties", "lib/fugit.rb", "lib/icons", "lib/icons/asterisk_yellow.png", "lib/icons/disk.png", "lib/icons/folder_add.png", "lib/icons/folder_delete.png", "lib/icons/page_add.png", "lib/icons/page_delete.png", "lib/icons/page_down.gif", "lib/icons/page_up.gif", "lib/icons/plus_minus.gif", "lib/icons/script.png", "lib/icons/script_add.png", "lib/icons/script_delete.png", "lib/icons/script_edit.png", "lib/icons/text_signature.png", "lib/icons/tick.png"]
|
13
13
|
s.has_rdoc = true
|
14
14
|
s.homepage = %q{http://github.com/tekkub/fugit}
|
15
15
|
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
|
data/lib/fugit.rb
CHANGED
@@ -6,10 +6,14 @@ require 'wx'
|
|
6
6
|
require "fugit/messages"
|
7
7
|
require "fugit/icon_loader"
|
8
8
|
require "fugit/main_frame"
|
9
|
+
require "fugit/commit_tab"
|
9
10
|
require "fugit/commit"
|
10
11
|
require "fugit/console"
|
11
12
|
require "fugit/diff"
|
12
13
|
require "fugit/index_list"
|
14
|
+
require "fugit/history_tab"
|
15
|
+
require "fugit/graph_renderer"
|
16
|
+
require "fugit/history_list"
|
13
17
|
|
14
18
|
|
15
19
|
version = File.exist?(File.join(File.dirname(__FILE__), "..", ".git")) ? "Developer's alpha" : Gem.searcher.find("fugit").version.to_s rescue "Unknown"
|
data/lib/fugit/commit.rb
CHANGED
@@ -17,7 +17,7 @@ module Fugit
|
|
17
17
|
@toolbar.add_tool(102, "Sign off", get_icon("text_signature.png"), "Sign off")
|
18
18
|
@toolbar.add_separator
|
19
19
|
@toolbar.add_tool(103, "Push", get_icon("page_up.gif"), "Push")
|
20
|
-
@toolbar.add_tool(104, "Pull", get_icon("page_down.gif"), "Pull")
|
20
|
+
#~ @toolbar.add_tool(104, "Pull", get_icon("page_down.gif"), "Pull")
|
21
21
|
@toolbar.realize
|
22
22
|
|
23
23
|
box = BoxSizer.new(HORIZONTAL)
|
@@ -39,6 +39,7 @@ module Fugit
|
|
39
39
|
self.set_sizer(box)
|
40
40
|
|
41
41
|
evt_tool(101, :on_commit_clicked)
|
42
|
+
evt_tool(103, :on_push_clicked)
|
42
43
|
|
43
44
|
register_for_message(:save_clicked, :on_commit_clicked)
|
44
45
|
register_for_message(:commit_saved, :on_commit_saved)
|
@@ -94,5 +95,9 @@ module Fugit
|
|
94
95
|
!staged.empty?
|
95
96
|
end
|
96
97
|
|
98
|
+
def on_push_clicked
|
99
|
+
`git push origin HEAD`
|
100
|
+
end
|
101
|
+
|
97
102
|
end
|
98
103
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
include Wx
|
2
|
+
include IconLoader
|
3
|
+
|
4
|
+
module Fugit
|
5
|
+
class CommitTab < Panel
|
6
|
+
def initialize(parent)
|
7
|
+
super
|
8
|
+
|
9
|
+
@vsplitter = SplitterWindow.new(self, ID_ANY)
|
10
|
+
@vsplitter.set_minimum_pane_size(150)
|
11
|
+
|
12
|
+
@hsplitter = SplitterWindow.new(@vsplitter, ID_ANY)
|
13
|
+
@hsplitter.set_minimum_pane_size(150)
|
14
|
+
@hsplitter.set_sash_gravity(1.0)
|
15
|
+
|
16
|
+
@diff = Diff.new(@hsplitter)
|
17
|
+
@commit = Commit.new(@hsplitter)
|
18
|
+
@hsplitter.split_horizontally(@diff, @commit)
|
19
|
+
|
20
|
+
@index = IndexList.new(@vsplitter)
|
21
|
+
@vsplitter.split_vertically(@index, @hsplitter, 200)
|
22
|
+
|
23
|
+
box = BoxSizer.new(VERTICAL)
|
24
|
+
box.add(@vsplitter, 1, EXPAND)
|
25
|
+
self.set_sizer(box)
|
26
|
+
|
27
|
+
self.accelerator_table = AcceleratorTable.new(AcceleratorEntry.new(MOD_CMD, ?w, ID_EXIT))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/fugit/diff.rb
CHANGED
@@ -12,7 +12,9 @@ module Fugit
|
|
12
12
|
|
13
13
|
@list_menu = Menu.new
|
14
14
|
@menu_stage_chunk = @list_menu.append('Stage this chunk')
|
15
|
+
@menu_stage_line = @list_menu.append('Stage this line')
|
15
16
|
evt_menu(@menu_stage_chunk, :on_menu_stage_chunk)
|
17
|
+
evt_menu(@menu_stage_line, :on_menu_stage_line)
|
16
18
|
|
17
19
|
@text = TextCtrl.new(self, ID_ANY, nil, nil, nil, TE_MULTILINE|TE_DONTWRAP|TE_READONLY)
|
18
20
|
@text.hide
|
@@ -44,10 +46,26 @@ module Fugit
|
|
44
46
|
@list.delete_children(@root)
|
45
47
|
|
46
48
|
chunks.each do |chunk|
|
47
|
-
|
48
|
-
|
49
|
-
chunk.split("\n")
|
50
|
-
|
49
|
+
chunk_diff = header + "\n" + chunk
|
50
|
+
chunk_diff += "\n" if chunk_diff[-1..-1] != "\n" # git bitches if we don't have a proper newline at the end of the diff
|
51
|
+
lines = chunk.split("\n")
|
52
|
+
lines.each_index do |i|
|
53
|
+
line = lines[i]
|
54
|
+
line_diff = case line[0..0]
|
55
|
+
when "+", "-"
|
56
|
+
chunk_lines = chunk.split("\n")
|
57
|
+
diff_val = chunk_lines.first.match(/\A@@ -\d+,(\d+)/)[1].to_i + (line[0..0] == "+" ? 1 : -1)
|
58
|
+
chunk_lines[0] = chunk_lines.first.gsub(/\+(\d+),\d+/, '+\1,' + diff_val.to_s)
|
59
|
+
chunk_lines.delete_at(i)
|
60
|
+
chunk_lines.map! {|l| l.gsub(/\A-/, " ")}
|
61
|
+
chunk_lines.insert(i, line)
|
62
|
+
chunk_lines.reject! {|l| l[0..0] == "+" && l != line}
|
63
|
+
header + "\n" + chunk_lines.join("\n") + "\n"
|
64
|
+
else
|
65
|
+
""
|
66
|
+
end
|
67
|
+
|
68
|
+
id = @list.append_item(@root, line.gsub("\t", " "), -1, -1, [chunk_diff, line_diff, type])
|
51
69
|
|
52
70
|
color = case line[0..0]
|
53
71
|
when "+"
|
@@ -93,26 +111,35 @@ module Fugit
|
|
93
111
|
@menu_data = nil
|
94
112
|
unless @root == i
|
95
113
|
@menu_data = @list.get_item_data(i)
|
96
|
-
@list_menu.set_label(@menu_stage_chunk.get_id, (@menu_data[
|
114
|
+
@list_menu.set_label(@menu_stage_chunk.get_id, (@menu_data[2] == :staged ? "Unstage chunk" : "Stage chunk"))
|
115
|
+
@list_menu.set_label(@menu_stage_line.get_id, (@menu_data[2] == :staged ? "Unstage line" : "Stage line"))
|
116
|
+
@menu_stage_line.enable(!@menu_data[1].empty?)
|
97
117
|
@list.popup_menu(@list_menu)
|
98
118
|
end
|
99
119
|
end
|
100
120
|
|
101
121
|
def on_menu_stage_chunk(event)
|
102
|
-
apply_diff(
|
122
|
+
apply_diff(@menu_data[0], @menu_data[2]) if @menu_data
|
123
|
+
end
|
124
|
+
|
125
|
+
def on_menu_stage_line(event)
|
126
|
+
apply_diff(@menu_data[1], @menu_data[2]) if @menu_data
|
103
127
|
end
|
104
128
|
|
105
129
|
def on_double_click(event)
|
106
130
|
i = event.get_item
|
107
|
-
|
131
|
+
unless @root == i
|
132
|
+
menu_data = @list.get_item_data(i)
|
133
|
+
apply_diff(menu_data[1], menu_data[2]) if menu_data
|
134
|
+
end
|
108
135
|
end
|
109
136
|
|
110
137
|
def apply_diff(diff, type)
|
138
|
+
return if !diff or diff.empty?
|
111
139
|
reverse = (type == :staged ? "--reverse" : "")
|
112
140
|
diff_file = File.join(Dir.pwd, ".git", "fugit_partial.diff")
|
113
141
|
File.open(diff_file, "wb") {|f| f << diff} # Write out in binary mode to preserve newlines, otherwise git freaks out
|
114
142
|
`git apply --cached #{reverse} .git/fugit_partial.diff`
|
115
|
-
File.delete(diff_file)
|
116
143
|
send_message(:index_changed)
|
117
144
|
end
|
118
145
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Fugit
|
4
|
+
module GraphRenderer
|
5
|
+
def graphify(commits)
|
6
|
+
graph = []
|
7
|
+
branch_parents = [commits.first[0]]
|
8
|
+
commits.each do |sha, parents, comment|
|
9
|
+
parents = parents.split(" ")
|
10
|
+
branches = []
|
11
|
+
parent_found = false
|
12
|
+
children = branch_parents.select {|b| b == sha}
|
13
|
+
branch_parents.each do |parent|
|
14
|
+
indicator = "│"
|
15
|
+
indicator = " " if parent.empty?
|
16
|
+
indicator = "┼" if parent_found && children.size > 1 && !parent.empty?
|
17
|
+
indicator = "●" if sha == parent && !parent_found
|
18
|
+
indicator = "┘" if sha == parent && parent_found
|
19
|
+
children.shift if sha == parent && parent_found
|
20
|
+
parent_found = true if sha == parent
|
21
|
+
branches << indicator
|
22
|
+
end
|
23
|
+
sha_found = false
|
24
|
+
branch_parents.map! do |b|
|
25
|
+
match = sha_found && sha == b
|
26
|
+
sha_found = sha == b if !sha_found
|
27
|
+
match ? "" : b
|
28
|
+
end
|
29
|
+
if parents.empty?
|
30
|
+
branch_parents.delete(sha)
|
31
|
+
else
|
32
|
+
sha_index = branch_parents.index(sha)
|
33
|
+
branch_parents[sha_index] = parents.shift if sha_index
|
34
|
+
parents.each do |p|
|
35
|
+
branch_parents << p
|
36
|
+
branches << "┐" if sha_index
|
37
|
+
end
|
38
|
+
branches << "●" unless sha_index
|
39
|
+
if parents.empty?
|
40
|
+
found = false
|
41
|
+
branchoffs = branches.select{|b| b == "┘"}
|
42
|
+
branches.map! do |b|
|
43
|
+
val = !found ? b : case b
|
44
|
+
when "┘"
|
45
|
+
branchoffs.shift
|
46
|
+
"┴"
|
47
|
+
when " "
|
48
|
+
branchoffs.empty? ? " " : "─"
|
49
|
+
else
|
50
|
+
b
|
51
|
+
end
|
52
|
+
found ||= b == "●"
|
53
|
+
val
|
54
|
+
end
|
55
|
+
branches.reverse!
|
56
|
+
found = false
|
57
|
+
branches.map! do |b|
|
58
|
+
was_found = !found && b == "┴"
|
59
|
+
found = was_found if !found
|
60
|
+
was_found ? "┘" : b
|
61
|
+
end
|
62
|
+
branches.reverse!
|
63
|
+
else
|
64
|
+
found = false
|
65
|
+
branches.map! do |b|
|
66
|
+
val = !found ? b : case b
|
67
|
+
when "│"
|
68
|
+
"┼"
|
69
|
+
when "┘"
|
70
|
+
"┴"
|
71
|
+
when " "
|
72
|
+
"─"
|
73
|
+
else
|
74
|
+
b
|
75
|
+
end
|
76
|
+
found = b == "●" if !found
|
77
|
+
val
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
branch_parents.reverse!
|
82
|
+
matched = false
|
83
|
+
branch_parents.reject! do |parent|
|
84
|
+
match = !matched && parent == ""
|
85
|
+
matched = parent != "" if !matched
|
86
|
+
match
|
87
|
+
end
|
88
|
+
branch_parents.reverse!
|
89
|
+
graph << [branches.join, comment, sha]
|
90
|
+
end
|
91
|
+
graph
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
include Wx
|
3
|
+
include Fugit::GraphRenderer
|
4
|
+
|
5
|
+
module Fugit
|
6
|
+
class HistoryList < Panel
|
7
|
+
def initialize(parent)
|
8
|
+
super(parent, ID_ANY)
|
9
|
+
self.set_font(Font.new(8, FONTFAMILY_TELETYPE, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL))
|
10
|
+
|
11
|
+
@list = ListCtrl.new(self, ID_ANY, :style => LC_REPORT|LC_VRULES|NO_BORDER)
|
12
|
+
|
13
|
+
@box = BoxSizer.new(VERTICAL)
|
14
|
+
@box.add(@list, 1, EXPAND)
|
15
|
+
self.set_sizer(@box)
|
16
|
+
|
17
|
+
register_for_message(:history_tab_shown) do
|
18
|
+
update_list unless @has_initialized
|
19
|
+
@list.set_focus
|
20
|
+
end
|
21
|
+
register_for_message(:exiting) {self.hide} # Things seem to run smoother if we hide before destruction
|
22
|
+
end
|
23
|
+
|
24
|
+
def update_list
|
25
|
+
@list.hide
|
26
|
+
@list.clear_all
|
27
|
+
|
28
|
+
@list.insert_column(0, "Graph")
|
29
|
+
@list.insert_column(1, "SHA1")
|
30
|
+
@list.insert_column(2, "Commit note")
|
31
|
+
|
32
|
+
mono_font = Font.new(8, FONTFAMILY_TELETYPE, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL)
|
33
|
+
|
34
|
+
output = `git log --pretty=format:"%H\t%P\t%s" --date-order --all`
|
35
|
+
lines = output.split("\n").map! {|line| line.split("\t")}
|
36
|
+
log = graphify(lines)
|
37
|
+
|
38
|
+
log.each_index do |i|
|
39
|
+
(graph, comment, sha) = log[i]
|
40
|
+
@list.insert_item(i, sha)
|
41
|
+
@list.set_item(i, 0, graph)
|
42
|
+
@list.set_item(i, 1, sha[0..7])
|
43
|
+
@list.set_item(i, 2, (comment.nil? || comment.empty?) ? "<No comment>" : comment)
|
44
|
+
end
|
45
|
+
|
46
|
+
@list.set_column_width(0, -1)
|
47
|
+
@list.set_column_width(1, -1)
|
48
|
+
@list.set_column_width(2, -2)
|
49
|
+
|
50
|
+
@list.show
|
51
|
+
@has_initialized = true
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
include Wx
|
2
|
+
include IconLoader
|
3
|
+
|
4
|
+
module Fugit
|
5
|
+
class HistroyTab < Panel
|
6
|
+
def initialize(parent)
|
7
|
+
super
|
8
|
+
|
9
|
+
@history_list = HistoryList.new(self)
|
10
|
+
|
11
|
+
box = BoxSizer.new(VERTICAL)
|
12
|
+
box.add(@history_list, 1, EXPAND)
|
13
|
+
self.set_sizer(box)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/fugit/index_list.rb
CHANGED
@@ -25,13 +25,23 @@ module Fugit
|
|
25
25
|
|
26
26
|
@toolbar = ToolBar.new(self, ID_ANY, nil, nil, TB_HORIZONTAL|NO_BORDER|TB_NODIVIDER)
|
27
27
|
@toolbar.set_tool_bitmap_size(Size.new(16,16))
|
28
|
-
@toolbar.add_tool(
|
29
|
-
@toolbar.add_tool(
|
28
|
+
stage_all_button = @toolbar.add_tool(ID_ANY, "Stage all", get_icon("folder_add.png"), "Stage all")
|
29
|
+
stage_button = @toolbar.add_tool(ID_ANY, "Stage", get_icon("page_add.png"), "Stage file")
|
30
30
|
@toolbar.add_separator
|
31
|
-
@toolbar.add_tool(
|
32
|
-
@toolbar.add_tool(
|
31
|
+
unstage_button = @toolbar.add_tool(ID_ANY, "Unstage", get_icon("page_delete.png"), "Unstage file")
|
32
|
+
unstage_all_button = @toolbar.add_tool(ID_ANY, "Unstage all", get_icon("folder_delete.png"), "Unstage all")
|
33
33
|
@toolbar.realize
|
34
34
|
|
35
|
+
@unstaged_menu = Menu.new
|
36
|
+
@menu_stage_file = @unstaged_menu.append('Stage file')
|
37
|
+
@menu_revert_changes = @unstaged_menu.append('Revert changes')
|
38
|
+
@staged_menu = Menu.new
|
39
|
+
@menu_unstage_file = @staged_menu.append('Unstage file')
|
40
|
+
evt_menu(@menu_stage_file, :on_menu_stage_file)
|
41
|
+
evt_menu(@menu_revert_changes, :on_menu_revert_changes)
|
42
|
+
evt_menu(@menu_unstage_file, :on_menu_stage_file)
|
43
|
+
evt_tree_item_menu(@index.get_id, :on_menu_request)
|
44
|
+
|
35
45
|
box = BoxSizer.new(VERTICAL)
|
36
46
|
box.add(@toolbar, 0, EXPAND)
|
37
47
|
box.add(@index, 1, EXPAND)
|
@@ -40,8 +50,8 @@ module Fugit
|
|
40
50
|
evt_tree_sel_changed(@index.get_id, :on_click)
|
41
51
|
evt_tree_item_activated(@index.get_id, :on_double_click)
|
42
52
|
|
43
|
-
evt_tool(
|
44
|
-
evt_tool(
|
53
|
+
evt_tool(stage_all_button, :on_stage_all_clicked)
|
54
|
+
evt_tool(unstage_all_button, :on_unstage_all_clicked)
|
45
55
|
|
46
56
|
evt_tree_item_collapsing(@index.get_id) {|event| event.veto}
|
47
57
|
|
@@ -131,20 +141,7 @@ module Fugit
|
|
131
141
|
def on_double_click(event)
|
132
142
|
i = event.get_item
|
133
143
|
unless i == @unstaged || i == @staged
|
134
|
-
(
|
135
|
-
case status
|
136
|
-
when :unstaged
|
137
|
-
case change
|
138
|
-
when :deleted
|
139
|
-
`git rm --cached "#{file}"`
|
140
|
-
else
|
141
|
-
`git add "#{file}"`
|
142
|
-
end
|
143
|
-
when :staged
|
144
|
-
`git reset "#{file}"`
|
145
|
-
end
|
146
|
-
|
147
|
-
send_message(:index_changed)
|
144
|
+
process_staging(*@index.get_item_data(i))
|
148
145
|
end
|
149
146
|
end
|
150
147
|
|
@@ -171,16 +168,60 @@ module Fugit
|
|
171
168
|
val = File.read(file)
|
172
169
|
send_message(:diff_raw, val)
|
173
170
|
when :modified, :deleted
|
174
|
-
val = `git diff -- #{file}`
|
171
|
+
val = `git diff -- "#{file}"`
|
175
172
|
send_message(:diff_set, val, :unstaged)
|
176
173
|
else
|
177
174
|
send_message(:diff_clear)
|
178
175
|
end
|
179
176
|
when :staged
|
180
|
-
val = `git diff --cached -- #{file}`
|
177
|
+
val = `git diff --cached -- "#{file}"`
|
181
178
|
send_message(:diff_set, val, :staged)
|
182
179
|
end
|
183
180
|
end
|
184
181
|
|
182
|
+
def on_menu_request(event)
|
183
|
+
i = event.get_item
|
184
|
+
@menu_data = nil
|
185
|
+
unless [@root, @staged, @unstaged].include?(i)
|
186
|
+
@menu_data = @index.get_item_data(i)
|
187
|
+
@menu_revert_changes.enable(@menu_data[1] != :new)
|
188
|
+
@index.popup_menu(@menu_data[2] == :staged ? @staged_menu : @unstaged_menu)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def on_menu_stage_file(event)
|
193
|
+
process_staging(*@menu_data) if @menu_data
|
194
|
+
end
|
195
|
+
|
196
|
+
def on_menu_revert_changes(event)
|
197
|
+
@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)
|
198
|
+
|
199
|
+
if @confirm_revert.show_modal == ID_YES
|
200
|
+
diff = `git diff -- "#{@menu_data[0]}"`
|
201
|
+
diff_file = File.join(Dir.pwd, ".git", "fugit_partial.diff")
|
202
|
+
File.open(diff_file, "wb") {|f| f << diff} # Write out in binary mode to preserve newlines, otherwise git freaks out
|
203
|
+
`git apply --reverse .git/fugit_partial.diff`
|
204
|
+
File.delete(diff_file)
|
205
|
+
|
206
|
+
send_message(:index_changed)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def process_staging(file, change, status)
|
211
|
+
case status
|
212
|
+
when :unstaged
|
213
|
+
case change
|
214
|
+
when :deleted
|
215
|
+
`git rm --cached "#{file}"`
|
216
|
+
else
|
217
|
+
`git add "#{file}"`
|
218
|
+
end
|
219
|
+
when :staged
|
220
|
+
`git reset "#{file}"`
|
221
|
+
end
|
222
|
+
|
223
|
+
send_message(:index_changed)
|
224
|
+
end
|
225
|
+
|
185
226
|
end
|
186
227
|
end
|
data/lib/fugit/main_frame.rb
CHANGED
@@ -3,24 +3,29 @@ include IconLoader
|
|
3
3
|
|
4
4
|
module Fugit
|
5
5
|
class MainFrame < Frame
|
6
|
-
attr_accessor :app_verion, :index, :commit, :diff
|
7
|
-
|
8
6
|
def initialize(title, version)
|
9
7
|
pwd = setup_working_directory
|
10
|
-
super(nil, :title => "#{pwd} - #{title}", :size => [ 800, 600 ])
|
8
|
+
super(nil, :title => "#{pwd} - #{title}#{version == "Developer's alpha" ? " ~~ALPHA~~" : ""}", :size => [ 800, 600 ])
|
9
|
+
|
10
|
+
@app_verion = version
|
11
11
|
|
12
|
-
|
12
|
+
@notebook = Notebook.new(self, ID_ANY, :style => FULL_REPAINT_ON_RESIZE)
|
13
|
+
@commit_panel = CommitTab.new(@notebook)
|
14
|
+
@history_panel = HistroyTab.new(@notebook)
|
15
|
+
@notebook.add_page(@commit_panel, "Commit", true)
|
16
|
+
@notebook.add_page(@history_panel, "History")
|
13
17
|
|
14
|
-
|
15
|
-
@
|
16
|
-
|
18
|
+
box = BoxSizer.new(VERTICAL)
|
19
|
+
box.add(@notebook, 1, EXPAND)
|
20
|
+
self.set_sizer(box)
|
17
21
|
|
18
22
|
set_min_size(Size.new(400,300))
|
19
|
-
setup_panes
|
20
23
|
|
21
24
|
icon_file = File.expand_path(File.join(IconBasePath, "plus_minus.gif"))
|
22
25
|
self.icon = Icon.new(icon_file, BITMAP_TYPE_GIF)
|
23
26
|
|
27
|
+
evt_notebook_page_changed(@notebook) {|event| send_message(:history_tab_shown) if event.get_selection == 1}
|
28
|
+
|
24
29
|
menu_bar = MenuBar.new
|
25
30
|
|
26
31
|
# The "file" menu
|
@@ -42,23 +47,16 @@ module Fugit
|
|
42
47
|
evt_menu(ID_SAVE) {|event| send_message(:save_clicked)}
|
43
48
|
evt_menu(refresh) {|event| send_message(:refresh)}
|
44
49
|
evt_menu(ID_EXIT) {|event| close} # End the application; it should finish automatically when the last window is closed.
|
45
|
-
evt_menu(ID_ABOUT
|
50
|
+
evt_menu(ID_ABOUT) do |event|
|
51
|
+
Wx::about_box(:name => self.title, :version => @app_verion, :description => "WxRuby-based git GUI", :developers => ['tekkub - http://tekkub.github.com'])
|
52
|
+
end
|
46
53
|
evt_close() do |event|
|
47
54
|
send_message(:exiting) # Notify listeners that we're closing up shop
|
48
55
|
destroy
|
49
56
|
exit
|
50
57
|
end
|
51
|
-
|
52
|
-
self.accelerator_table = AcceleratorTable.new(AcceleratorEntry.new(MOD_CMD, ?w, ID_EXIT))
|
53
|
-
|
54
|
-
@mgr.update
|
55
58
|
end
|
56
59
|
|
57
|
-
|
58
|
-
#####################
|
59
|
-
## Setup ##
|
60
|
-
#####################
|
61
|
-
|
62
60
|
def setup_working_directory
|
63
61
|
orig = Dir.pwd
|
64
62
|
last_dir = nil
|
@@ -70,34 +68,5 @@ module Fugit
|
|
70
68
|
File.basename(Dir.pwd)
|
71
69
|
end
|
72
70
|
|
73
|
-
def setup_panes
|
74
|
-
pi = AuiPaneInfo.new
|
75
|
-
size = Size.new(800, 150)
|
76
|
-
pi.bottom.set_name('commit').set_caption("Commit").set_layer(1).set_position(1).set_best_size(size).set_min_size(size).set_floating_size(size)
|
77
|
-
@commit = Commit.new(self)
|
78
|
-
@mgr.add_pane(@commit, pi)
|
79
|
-
|
80
|
-
#~ pi = AuiPaneInfo.new
|
81
|
-
#~ size = Size.new(800, 75)
|
82
|
-
#~ pi.bottom.set_name('console').set_caption("Console").set_layer(3).set_position(1).set_best_size(size).set_min_size(size).set_floating_size(size).set_maximize_button.set_minimize_button
|
83
|
-
#~ @mgr.add_pane(Console.new(self), pi)
|
84
|
-
|
85
|
-
pi = AuiPaneInfo.new
|
86
|
-
size = Size.new(200, 350)
|
87
|
-
pi.left.set_name('index').set_caption("Index").set_layer(2).set_position(1).set_best_size(size).set_min_size(size).set_floating_size(size)
|
88
|
-
@index = IndexList.new(self)
|
89
|
-
@mgr.add_pane(@index, pi)
|
90
|
-
|
91
|
-
pi = AuiPaneInfo.new
|
92
|
-
size = Size.new(200, 350)
|
93
|
-
pi.center_pane.set_name('diff')
|
94
|
-
@diff = Diff.new(self)
|
95
|
-
@mgr.add_pane(@diff, pi)
|
96
|
-
end
|
97
|
-
|
98
|
-
def on_about
|
99
|
-
Wx::about_box(:name => self.title, :version => self.app_verion, :description => "WxRuby-based git GUI", :developers => ['tekkub - http://tekkub.github.com'])
|
100
|
-
end
|
101
|
-
|
102
71
|
end
|
103
72
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tekkub-fugit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tekkub
|
@@ -9,11 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-17 00:00:00 -08:00
|
13
13
|
default_executable: fugit
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: wxruby
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -36,8 +37,12 @@ files:
|
|
36
37
|
- bin/fugit
|
37
38
|
- lib/fugit
|
38
39
|
- lib/fugit/commit.rb
|
40
|
+
- lib/fugit/commit_tab.rb
|
39
41
|
- lib/fugit/console.rb
|
40
42
|
- lib/fugit/diff.rb
|
43
|
+
- lib/fugit/graph_renderer.rb
|
44
|
+
- lib/fugit/history_list.rb
|
45
|
+
- lib/fugit/history_tab.rb
|
41
46
|
- lib/fugit/icon_loader.rb
|
42
47
|
- lib/fugit/index_list.rb
|
43
48
|
- lib/fugit/main_frame.rb
|