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
@@ -0,0 +1,66 @@
1
+ module Grit
2
+
3
+ class Tag < Ref
4
+ def self.find_all(repo, options = {})
5
+ refs = []
6
+ already = {}
7
+
8
+ Dir.chdir(repo.path) do
9
+ files = Dir.glob(prefix + '/**/*')
10
+
11
+ files.each do |ref|
12
+ next if !File.file?(ref)
13
+
14
+ id = File.read(ref).chomp
15
+ name = ref.sub("#{prefix}/", '')
16
+ commit = commit_from_sha(repo, id)
17
+
18
+ if !already[name]
19
+ refs << self.new(name, commit)
20
+ already[name] = true
21
+ end
22
+ end
23
+
24
+ if File.file?('packed-refs')
25
+ lines = File.readlines('packed-refs')
26
+ lines.each_with_index do |line, i|
27
+ if m = /^(\w{40}) (.*?)$/.match(line)
28
+ next if !Regexp.new('^' + prefix).match(m[2])
29
+ name = m[2].sub("#{prefix}/", '')
30
+
31
+ # Annotated tags in packed-refs include a reference
32
+ # to the commit object on the following line.
33
+ next_line = lines[i+1]
34
+ if next_line && next_line[0] == ?^
35
+ commit = Commit.create(repo, :id => next_line[1..-1].chomp)
36
+ else
37
+ commit = commit_from_sha(repo, m[1])
38
+ end
39
+
40
+ if !already[name]
41
+ refs << self.new(name, commit)
42
+ already[name] = true
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ refs
50
+ end
51
+
52
+ def self.commit_from_sha(repo, id)
53
+ git_ruby_repo = GitRuby::Repository.new(repo.path)
54
+ object = git_ruby_repo.get_object_by_sha1(id)
55
+
56
+ if object.type == :commit
57
+ Commit.create(repo, :id => id)
58
+ elsif object.type == :tag
59
+ Commit.create(repo, :id => object.object)
60
+ else
61
+ raise "Unknown object type."
62
+ end
63
+ end
64
+ end
65
+
66
+ end
@@ -0,0 +1,104 @@
1
+ module Grit
2
+
3
+ class Tree
4
+ lazy_reader :contents
5
+ attr_reader :id
6
+ attr_reader :mode
7
+ attr_reader :name
8
+
9
+ # Construct the contents of the tree
10
+ # +repo+ is the Repo
11
+ # +treeish+ is the reference
12
+ # +paths+ is an optional Array of directory paths to restrict the tree
13
+ #
14
+ # Returns Grit::Tree (baked)
15
+ def self.construct(repo, treeish, paths = [])
16
+ output = repo.git.ls_tree({}, treeish, *paths)
17
+ self.allocate.construct_initialize(repo, treeish, output)
18
+ end
19
+
20
+ def construct_initialize(repo, id, text)
21
+ @repo = repo
22
+ @id = id
23
+ @contents = []
24
+
25
+ text.split("\n").each do |line|
26
+ @contents << content_from_string(repo, line)
27
+ end
28
+ @contents.compact!
29
+
30
+ self
31
+ end
32
+
33
+ def lazy_source
34
+ Tree.construct(@repo, @id, [])
35
+ end
36
+
37
+ # Create an unbaked Tree containing just the specified attributes
38
+ # +repo+ is the Repo
39
+ # +atts+ is a Hash of instance variable data
40
+ #
41
+ # Returns Grit::Tree (unbaked)
42
+ def self.create(repo, atts)
43
+ self.allocate.create_initialize(repo, atts)
44
+ end
45
+
46
+ # Initializer for Tree.create
47
+ # +repo+ is the Repo
48
+ # +atts+ is a Hash of instance variable data
49
+ #
50
+ # Returns Grit::Tree (unbaked)
51
+ def create_initialize(repo, atts)
52
+ @repo = repo
53
+
54
+ atts.each do |k, v|
55
+ instance_variable_set("@#{k}", v)
56
+ end
57
+ self
58
+ end
59
+
60
+ # Parse a content item and create the appropriate object
61
+ # +repo+ is the Repo
62
+ # +text+ is the single line containing the items data in `git ls-tree` format
63
+ #
64
+ # Returns Grit::Blob or Grit::Tree
65
+ def content_from_string(repo, text)
66
+ mode, type, id, name = text.split(" ", 4)
67
+ case type
68
+ when "tree"
69
+ Tree.create(repo, :id => id, :mode => mode, :name => name)
70
+ when "blob"
71
+ Blob.create(repo, :id => id, :mode => mode, :name => name)
72
+ when "link"
73
+ Blob.create(repo, :id => id, :mode => mode, :name => name)
74
+ when "commit"
75
+ Submodule.create(repo, :id => id, :mode => mode, :name => name)
76
+ else
77
+ raise "Invalid type: #{type}"
78
+ end
79
+ end
80
+
81
+ # Find the named object in this tree's contents
82
+ #
83
+ # Examples
84
+ # Repo.new('/path/to/grit').tree/'lib'
85
+ # # => #<Grit::Tree "6cc23ee138be09ff8c28b07162720018b244e95e">
86
+ # Repo.new('/path/to/grit').tree/'README.txt'
87
+ # # => #<Grit::Blob "8b1e02c0fb554eed2ce2ef737a68bb369d7527df">
88
+ #
89
+ # Returns Grit::Blob or Grit::Tree or nil if not found
90
+ def /(file)
91
+ if file =~ /\//
92
+ file.split("/").inject(self) { |acc, x| acc/x } rescue nil
93
+ else
94
+ self.contents.find { |c| c.name == file }
95
+ end
96
+ end
97
+
98
+ # Pretty object inspection
99
+ def inspect
100
+ %Q{#<Grit::Tree "#{@id}">}
101
+ end
102
+ end # Tree
103
+
104
+ end # Grit
@@ -0,0 +1,71 @@
1
+ $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
2
+
3
+ # core
4
+ require 'fileutils'
5
+ require 'time'
6
+
7
+ # stdlib
8
+ require 'timeout'
9
+ require 'logger'
10
+ require 'digest/sha1'
11
+
12
+ if defined? RUBY_ENGINE && RUBY_ENGINE == 'jruby'
13
+ require 'open3'
14
+ elsif RUBY_PLATFORM =~ /mswin|mingw/
15
+ begin
16
+ require 'win32/open3'
17
+ rescue LoadError
18
+ warn "You must 'gem install win32-open3' to use grit on Windows"
19
+ exit 1
20
+ end
21
+ else
22
+ require 'open3_detach'
23
+ end
24
+
25
+ # third party
26
+ require 'rubygems'
27
+ require 'mime/types'
28
+
29
+ # internal requires
30
+ require 'grit/lazy'
31
+ require 'grit/errors'
32
+ require 'grit/git-ruby'
33
+ require 'grit/git'
34
+ require 'grit/ref'
35
+ require 'grit/tag'
36
+ require 'grit/commit'
37
+ require 'grit/commit_stats'
38
+ require 'grit/tree'
39
+ require 'grit/blob'
40
+ require 'grit/actor'
41
+ require 'grit/diff'
42
+ require 'grit/config'
43
+ require 'grit/repo'
44
+ require 'grit/index'
45
+ require 'grit/status'
46
+ require 'grit/submodule'
47
+ require 'grit/blame'
48
+ require 'grit/merge'
49
+
50
+
51
+ module Grit
52
+ class << self
53
+ # Set +debug+ to true to log all git calls and responses
54
+ attr_accessor :debug
55
+ attr_accessor :use_git_ruby
56
+ # The standard +logger+ for debugging git calls - this defaults to a plain STDOUT logger
57
+ attr_accessor :logger
58
+ def log(str)
59
+ logger.debug { str }
60
+ end
61
+ end
62
+ self.debug = false
63
+ self.use_git_ruby = true
64
+
65
+ @logger ||= ::Logger.new(STDOUT)
66
+
67
+ def self.version
68
+ yml = YAML.load(File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION.yml])))
69
+ "#{yml[:major]}.#{yml[:minor]}.#{yml[:patch]}"
70
+ end
71
+ end
@@ -0,0 +1,46 @@
1
+ module Open3
2
+ extend self
3
+
4
+ def popen3(*cmd)
5
+ pw = IO::pipe # pipe[0] for read, pipe[1] for write
6
+ pr = IO::pipe
7
+ pe = IO::pipe
8
+
9
+ pid = fork{
10
+ # child
11
+ fork{
12
+ # grandchild
13
+ pw[1].close
14
+ STDIN.reopen(pw[0])
15
+ pw[0].close
16
+
17
+ pr[0].close
18
+ STDOUT.reopen(pr[1])
19
+ pr[1].close
20
+
21
+ pe[0].close
22
+ STDERR.reopen(pe[1])
23
+ pe[1].close
24
+
25
+ exec(*cmd)
26
+ }
27
+ exit!(0)
28
+ }
29
+
30
+ pw[0].close
31
+ pr[1].close
32
+ pe[1].close
33
+ Process.waitpid(pid)
34
+ pi = [pw[1], pr[0], pe[0]]
35
+ pw[1].sync = true
36
+ if defined? yield
37
+ begin
38
+ return yield(*pi)
39
+ ensure
40
+ Process.detach(pid) if pid
41
+ pi.each { |p| p.close unless p.closed? }
42
+ end
43
+ end
44
+ pi
45
+ end
46
+ end
Binary file
Binary file
Binary file
Binary file
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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tekkub
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-27 00:00:00 -08:00
12
+ date: 2009-05-05 00:00:00 -07:00
13
13
  default_executable: fugit
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -31,35 +31,82 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
 
33
33
  files:
34
- - fugit.gemspec
35
- - SciTE.properties
34
+ - Rakefile
36
35
  - VERSION.yml
37
36
  - bin/fugit
38
- - lib/fugit
37
+ - lib/fugit.rb
39
38
  - lib/fugit/commit_dialog.rb
40
39
  - lib/fugit/commit_tab.rb
41
- - lib/fugit/commit_tab_toolbar.rb
42
40
  - lib/fugit/console.rb
41
+ - lib/fugit/create_branch_dialog.rb
43
42
  - lib/fugit/delete_branch_dialog.rb
44
43
  - lib/fugit/diff.rb
44
+ - lib/fugit/fetch_dialog.rb
45
45
  - lib/fugit/graph_renderer.rb
46
46
  - lib/fugit/history_list.rb
47
47
  - lib/fugit/history_tab.rb
48
48
  - lib/fugit/icon_loader.rb
49
49
  - lib/fugit/index_list.rb
50
50
  - lib/fugit/io_get_line.rb
51
+ - lib/fugit/logged_dialog.rb
51
52
  - lib/fugit/main_frame.rb
53
+ - lib/fugit/merge_dialog.rb
52
54
  - lib/fugit/messages.rb
53
55
  - lib/fugit/push_dialog.rb
54
- - lib/fugit/SciTE.properties
55
- - lib/fugit.rb
56
- - lib/icons
56
+ - lib/fugit/revert_commit_dialog.rb
57
+ - lib/fugit/run_command_dialog.rb
58
+ - lib/fugit/tab_toolbar.rb
59
+ - lib/grit/API.txt
60
+ - lib/grit/History.txt
61
+ - lib/grit/PURE_TODO
62
+ - lib/grit/README.txt
63
+ - lib/grit/Rakefile
64
+ - lib/grit/VERSION.yml
65
+ - lib/grit/benchmarks.rb
66
+ - lib/grit/benchmarks.txt
67
+ - lib/grit/examples/ex_add_commit.rb
68
+ - lib/grit/examples/ex_index.rb
69
+ - lib/grit/grit.gemspec
70
+ - lib/grit/lib/grit.rb
71
+ - lib/grit/lib/grit/actor.rb
72
+ - lib/grit/lib/grit/blame.rb
73
+ - lib/grit/lib/grit/blob.rb
74
+ - lib/grit/lib/grit/commit.rb
75
+ - lib/grit/lib/grit/commit_stats.rb
76
+ - lib/grit/lib/grit/config.rb
77
+ - lib/grit/lib/grit/diff.rb
78
+ - lib/grit/lib/grit/errors.rb
79
+ - lib/grit/lib/grit/git-ruby.rb
80
+ - lib/grit/lib/grit/git-ruby/commit_db.rb
81
+ - lib/grit/lib/grit/git-ruby/file_index.rb
82
+ - lib/grit/lib/grit/git-ruby/git_object.rb
83
+ - lib/grit/lib/grit/git-ruby/internal/loose.rb
84
+ - lib/grit/lib/grit/git-ruby/internal/mmap.rb
85
+ - lib/grit/lib/grit/git-ruby/internal/pack.rb
86
+ - lib/grit/lib/grit/git-ruby/internal/raw_object.rb
87
+ - lib/grit/lib/grit/git-ruby/object.rb
88
+ - lib/grit/lib/grit/git-ruby/repository.rb
89
+ - lib/grit/lib/grit/git.rb
90
+ - lib/grit/lib/grit/index.rb
91
+ - lib/grit/lib/grit/lazy.rb
92
+ - lib/grit/lib/grit/merge.rb
93
+ - lib/grit/lib/grit/ref.rb
94
+ - lib/grit/lib/grit/repo.rb
95
+ - lib/grit/lib/grit/status.rb
96
+ - lib/grit/lib/grit/submodule.rb
97
+ - lib/grit/lib/grit/tag.rb
98
+ - lib/grit/lib/grit/tree.rb
99
+ - lib/grit/lib/open3_detach.rb
100
+ - lib/icons/application_go.png
57
101
  - lib/icons/arrow_divide.png
102
+ - lib/icons/arrow_divide_add.png
58
103
  - lib/icons/arrow_divide_delete.png
59
104
  - lib/icons/arrow_join.png
105
+ - lib/icons/arrow_refresh.png
60
106
  - lib/icons/arrow_undo.png
61
107
  - lib/icons/asterisk_yellow.png
62
108
  - lib/icons/cherry.png
109
+ - lib/icons/cross.png
63
110
  - lib/icons/disk.png
64
111
  - lib/icons/folder_add.png
65
112
  - lib/icons/folder_delete.png
@@ -78,7 +125,6 @@ has_rdoc: true
78
125
  homepage: http://github.com/tekkub/fugit
79
126
  post_install_message:
80
127
  rdoc_options:
81
- - --inline-source
82
128
  - --charset=UTF-8
83
129
  require_paths:
84
130
  - lib
data/fugit.gemspec DELETED
@@ -1,32 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = %q{fugit}
3
- s.version = "0.0.5"
4
-
5
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
- s.authors = ["Tekkub"]
7
- s.date = %q{2009-02-27}
8
- s.default_executable = %q{fugit}
9
- s.description = %q{A cross-platform replacement for git-gui based on wxruby}
10
- s.email = %q{tekkub@gmail.com}
11
- s.executables = ["fugit"]
12
- s.files = ["fugit.gemspec", "SciTE.properties", "VERSION.yml", "bin/fugit", "lib/fugit", "lib/fugit/commit_dialog.rb", "lib/fugit/commit_tab.rb", "lib/fugit/commit_tab_toolbar.rb", "lib/fugit/console.rb", "lib/fugit/delete_branch_dialog.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/io_get_line.rb", "lib/fugit/main_frame.rb", "lib/fugit/messages.rb", "lib/fugit/push_dialog.rb", "lib/fugit/SciTE.properties", "lib/fugit.rb", "lib/icons", "lib/icons/arrow_divide.png", "lib/icons/arrow_divide_delete.png", "lib/icons/arrow_join.png", "lib/icons/arrow_undo.png", "lib/icons/asterisk_yellow.png", "lib/icons/cherry.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
- s.has_rdoc = true
14
- s.homepage = %q{http://github.com/tekkub/fugit}
15
- s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
16
- s.require_paths = ["lib"]
17
- s.rubygems_version = %q{1.2.0}
18
- s.summary = %q{A cross-platform replacement for git-gui based on wxruby}
19
-
20
- if s.respond_to? :specification_version then
21
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
22
- s.specification_version = 2
23
-
24
- if current_version >= 3 then
25
- s.add_runtime_dependency(%q<wxruby>, [">= 1.9.9"])
26
- else
27
- s.add_dependency(%q<wxruby>, [">= 1.9.9"])
28
- end
29
- else
30
- s.add_dependency(%q<wxruby>, [">= 1.9.9"])
31
- end
32
- end
@@ -1,111 +0,0 @@
1
- include Wx
2
- include IconLoader
3
-
4
- module Fugit
5
- class CommitTabToolbar < ToolBar
6
- def initialize(parent)
7
- super(parent, ID_ANY, nil, nil, TB_HORIZONTAL|NO_BORDER|TB_NODIVIDER)
8
-
9
- self.set_tool_bitmap_size(Size.new(16,16))
10
-
11
- stage_all_button = self.add_tool(ID_ANY, "Stage all", get_icon("folder_add.png"), "Stage all")
12
- evt_tool(stage_all_button, :on_stage_all_clicked)
13
-
14
- stage_button = self.add_tool(ID_ANY, "Stage", get_icon("page_add.png"), "Stage changed files")
15
- evt_tool(stage_button, :on_stage_changed_clicked)
16
-
17
- unstage_all_button = self.add_tool(ID_ANY, "Unstage all", get_icon("folder_delete.png"), "Unstage all")
18
- evt_tool(unstage_all_button, :on_unstage_all_clicked)
19
-
20
- self.add_separator
21
-
22
- commit = self.add_tool(ID_ANY, "Commit", get_icon("disk.png"), "Commit")
23
- evt_tool(commit, :on_commit_clicked)
24
-
25
- self.add_separator
26
-
27
- push = self.add_tool(ID_ANY, "Push", get_icon("page_up.gif"), "Push")
28
- evt_tool(push, :on_push_clicked)
29
-
30
- pull = self.add_tool(ID_ANY, "Pull", get_icon("page_down.gif"), "Pull")
31
- self.enable_tool(pull.get_id, false)
32
-
33
- self.add_separator
34
-
35
- self.add_control(@branch = Choice.new(self, ID_ANY))
36
- set_branches
37
- evt_choice(@branch, :on_branch_choice)
38
-
39
- merge_branch_button = self.add_tool(ID_ANY, "Merge branch", get_icon("arrow_join.png"), "Merge branch")
40
- self.enable_tool(merge_branch_button.get_id, false)
41
-
42
- delete_branch_button = self.add_tool(ID_ANY, "Delete branch", get_icon("arrow_divide_delete.png"), "Delete branch")
43
- evt_tool(delete_branch_button, :on_delete_branch_clicked)
44
-
45
- self.realize
46
-
47
- register_for_message(:tab_switch, :update_tools)
48
- register_for_message(:branch_deleted, :update_tools)
49
- register_for_message(:refresh, :update_tools)
50
- register_for_message(:save_clicked, :on_commit_clicked)
51
- register_for_message(:push_clicked, :on_push_clicked)
52
- end
53
-
54
- def update_tools
55
- return unless is_shown_on_screen
56
- set_branches
57
- end
58
-
59
- def set_branches
60
- branches = `git branch`
61
- current = branches.match(/\* (.+)/).to_a.last
62
- @branch.clear
63
- branches.split("\n").each {|b| @branch.append(b.split(" ").last)}
64
- @branch.set_string_selection(current) if current
65
- end
66
-
67
- def on_stage_all_clicked(event)
68
- `git add --all 2>&1`
69
- send_message(:index_changed)
70
- end
71
-
72
- def on_stage_changed_clicked(event)
73
- `git add --update 2>&1`
74
- send_message(:index_changed)
75
- end
76
-
77
- def on_unstage_all_clicked(event)
78
- `git reset 2>&1`
79
- send_message(:index_changed)
80
- end
81
-
82
- def on_commit_clicked
83
- @commit_dialog ||= CommitDialog.new(self)
84
- send_message(:commit_saved) if @commit_dialog.show_modal == ID_OK
85
- end
86
-
87
- def on_push_clicked
88
- @push_dialog ||= PushDialog.new(self)
89
- @push_dialog.show
90
- end
91
-
92
- def on_branch_choice(event)
93
- branch = @branch.get_string(event.get_selection)
94
- err = `git checkout #{branch} 2>&1`
95
- if err =~ /Switched to branch "#{branch}"/
96
- send_message(:branch_checkout)
97
- else
98
- MessageDialog.new(self, err, "Branch checkout error", OK|ICON_ERROR).show_modal
99
- branches = `git branch`
100
- current = branches.match(/\* (.+)/).to_a.last
101
- @branch.set_string_selection(current) if current
102
- end
103
- end
104
-
105
- def on_delete_branch_clicked
106
- @delete_branch_dialog ||= DeleteBranchDialog.new(self)
107
- @delete_branch_dialog.show
108
- end
109
-
110
- end
111
- end