diff --git a/Commands/Start Gitk.tmCommand b/Commands/Open in External App.tmCommand
similarity index 81%
rename from Commands/Start Gitk.tmCommand
rename to Commands/Open in External App.tmCommand
index 6ef9d32..be9ba76 100644
--- a/Commands/Start Gitk.tmCommand
+++ b/Commands/Open in External App.tmCommand
@@ -7,14 +7,14 @@
command
#!/usr/bin/env ruby18
require ENV['TM_BUNDLE_SUPPORT'] + '/environment.rb'
-dispatch(:controller => "misc", :action => "gitk")
+dispatch(:controller => "misc", :action => "external")
input
none
inputFormat
text
name
- Visualize Branch History With GitK
+ Visualize History with External Git App
outputCaret
afterOutput
outputFormat
@@ -26,7 +26,7 @@ dispatch(:controller => "misc", :action => "gitk")
semanticClass
action.scm.other
uuid
- 20F5C491-F71C-4963-9C61-DF7294976550
+ 547EFC07-D15D-4217-9695-9043232560FF
version
2
diff --git a/Commands/Use Git-Gui.tmCommand b/Commands/Use Git-Gui.tmCommand
deleted file mode 100644
index abeb6be..0000000
--- a/Commands/Use Git-Gui.tmCommand
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
- beforeRunningCommand
- nop
- command
- #!/usr/bin/env ruby18
-require ENV['TM_BUNDLE_SUPPORT'] + '/environment.rb'
-dispatch(:controller => "misc", :action => "gitgui")
- input
- selection
- inputFormat
- text
- name
- Open Git-Gui
- outputCaret
- afterOutput
- outputFormat
- text
- outputLocation
- discard
- scope
- attr.scm.git
- uuid
- D0DF4B19-F311-48CC-BF68-F8B33CD051D3
- version
- 2
-
-
diff --git a/Commands/Use GitX.tmCommand b/Commands/Use GitX.tmCommand
deleted file mode 100644
index 2c954fa..0000000
--- a/Commands/Use GitX.tmCommand
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
- beforeRunningCommand
- nop
- command
- #!/usr/bin/env ruby18
-require ENV['TM_BUNDLE_SUPPORT'] + '/environment.rb'
-dispatch(:controller => "misc", :action => "gitx")
-
- input
- none
- inputFormat
- text
- name
- Visualize History with GitX
- outputCaret
- afterOutput
- outputFormat
- text
- outputLocation
- discard
- scope
- attr.scm.git
- semanticClass
- action.scm.other
- uuid
- 1C12DE42-78A9-4DCA-BB55-2B8E6328C72D
- version
- 2
-
-
diff --git a/Commands/Use Gitnub.tmCommand b/Commands/Use Gitnub.tmCommand
deleted file mode 100644
index e49c840..0000000
--- a/Commands/Use Gitnub.tmCommand
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
- beforeRunningCommand
- nop
- command
- #!/usr/bin/env ruby18
-require ENV['TM_BUNDLE_SUPPORT'] + '/environment.rb'
-dispatch(:controller => "misc", :action => "gitnub")
-
- input
- selection
- inputFormat
- text
- name
- Visualize History with Gitnub
- outputCaret
- afterOutput
- outputFormat
- text
- outputLocation
- discard
- scope
- attr.scm.git
- semanticClass
- action.scm.other
- uuid
- 1FF5FF82-13A0-4C83-BAD6-D67AE8180FA9
- version
- 2
-
-
diff --git a/Support/app/controllers/misc_controller.rb b/Support/app/controllers/misc_controller.rb
index f156716..ad9ec6e 100644
--- a/Support/app/controllers/misc_controller.rb
+++ b/Support/app/controllers/misc_controller.rb
@@ -4,35 +4,28 @@ def init
puts "
Initializing Git Repository in #{ENV['TM_PROJECT_DIRECTORY']}
"
puts htmlize(git.init(ENV["TM_PROJECT_DIRECTORY"]))
end
-
- def gitk
- run_detached("PATH=#{File.dirname(git.git)}:$PATH && gitk --all", "Wish Shell")
- end
-
- def gitgui
- run_detached("PATH=#{File.dirname(git.git)}:$PATH && git gui", "Git Gui")
- end
-
- def gitnub
- cmd = first_which(git.config["git-tmbundle.gitnub-path"], "nub", "/Applications/GitNub.app/Contents/MacOS/GitNub")
- if cmd
- run_detached(cmd + " #{ENV['TM_PROJECT_DIRECTORY']}", "Gitnub")
- else
- puts "Unable to find Gitnub. Use the config dialog to set the Gitnub path to where you've installed it."
- output_show_tool_tip
- end
- end
-
- def gitx
- cmd = first_which(git.config["git-tmbundle.gitx-path"], "gitx", "/Applications/GitX.app/Contents/Resources/gitx")
- if cmd
- run_detached("cd '#{ENV['TM_DIRECTORY']}';" + cmd, "GitX")
+
+ def external
+ gui_type = git.config["git-tmbundle.ext-app"]
+ case gui_type
+ when "gitk"
+ ext_gitk
+ when "gitgui"
+ ext_gitgui
+ when "gitx"
+ ext_gitx
+ when "gitnub"
+ ext_gitnub
+ when "stree"
+ ext_stree
+ when "custom"
+ ext_custom
else
- puts "Unable to find GitX. Use the config dialog to set the GitX path to where you've installed it."
+ puts "Select an external GUI tool from the config dialog(Bundles → Git → Config...)."
output_show_tool_tip
end
end
-
+
protected
def first_which(*args)
args.map do |arg|
@@ -42,7 +35,7 @@ def first_which(*args)
end
nil
end
-
+
def run_detached(cmd, app_name)
exit if fork # Parent exits, child continues.
Process.setsid # Become session leader.
@@ -63,5 +56,53 @@ def run_detached(cmd, app_name)
Process.detach(pid)
#inspired by http://andrejserafim.wordpress.com/2007/12/16/multiple-threads-and-processes-in-ruby/
end
-
+
+ def ext_gitk
+ run_detached("cd '#{git.path()}'; PATH=#{File.dirname(git.git)}:$PATH && gitk --all", "Wish")
+ end
+
+ def ext_gitgui
+ run_detached("cd '#{git.path()}'; PATH=#{File.dirname(git.git)}:$PATH && git gui", "Git Gui")
+ end
+
+ def ext_gitnub
+ cmd = first_which(git.config["git-tmbundle.gitnub-path"], "nub", "/Applications/GitNub.app/Contents/MacOS/GitNub")
+ if cmd
+ run_detached(cmd + " #{ENV['TM_PROJECT_DIRECTORY']}", "Gitnub")
+ else
+ puts "Unable to find Gitnub. Use the config dialog to set the Gitnub path to where you've installed it."
+ output_show_tool_tip
+ end
+ end
+
+ def ext_gitx
+ cmd = first_which(git.config["git-tmbundle.gitx-path"], "gitx", "/Applications/GitX.app/Contents/Resources/gitx")
+ if cmd
+ run_detached("cd '#{ENV['TM_DIRECTORY']}';" + cmd, "GitX")
+ else
+ puts "Unable to find GitX. Use the config dialog to set the GitX path to where you've installed it."
+ output_show_tool_tip
+ end
+ end
+
+ def ext_stree
+ cmd = first_which(git.config["git-tmbundle.stree-path"], "stree", "/Applications/SourceTree.app/Contents/Resources/stree")
+ if cmd
+ run_detached("cd '#{git.path()}';" + cmd, "SourceTree")
+ else
+ puts "Unable to find SourceTree. Use the config dialog to set the SourceTree path to where you've installed it."
+ output_show_tool_tip
+ end
+ end
+
+ def ext_custom
+ cmd = git.config["git-tmbundle.ext-custom-cmd"]
+ if cmd
+ run_detached("cd '#{git.path()}'; " + cmd, "Custom Git GUI")
+ else
+ puts "Set the custom GUI command to use from the config dialog(Bundles → Git → Config...)."
+ output_show_tool_tip
+ end
+
+ end
end
\ No newline at end of file
diff --git a/Support/app/helpers/config_helper.rb b/Support/app/helpers/config_helper.rb
index 2a587d0..366e457 100644
--- a/Support/app/helpers/config_helper.rb
+++ b/Support/app/helpers/config_helper.rb
@@ -1,5 +1,30 @@
module ConfigHelper
+ def config_form_field(type, local_or_global, config_key, options = {})
+ if type == "select"
+ config_select_field(local_or_global, config_key, options)
+ else
+ config_text_field(local_or_global, config_key, options)
+ end
+ end
+
def config_text_field(local_or_global, config_key, options = {})
content_tag :input, {:type => "text", :value => git.config[local_or_global, config_key], :onchange => "dispatch({controller: 'config', action: 'set', scope: '#{local_or_global}', key: '#{config_key}', value: $F(this)})"}.merge(options)
end
-end
\ No newline at end of file
+
+ def config_select_field(local_or_global, config_key, options = {})
+ selected_value = git.config[local_or_global, config_key]
+ if options[:select_options]
+ select_options = options[:select_options].map do |value, label|
+ if selected_value.to_s == value.to_s
+ content_tag(:option, label, :value => value, :selected=>"selected")
+ else
+ content_tag(:option, label, :value => value)
+ end
+ end
+ else
+ select_options = []
+ end
+
+ content_tag(:select, select_options, {:mulitiple => false, :onchange => "dispatch({controller: 'config', action: 'set', scope: '#{local_or_global}', key: '#{config_key}', value: $F(this)})"}.merge(options).reject(:select_options))
+ end
+end
diff --git a/Support/app/views/config/index.html.erb b/Support/app/views/config/index.html.erb
index 5a83da9..edd57cb 100644
--- a/Support/app/views/config/index.html.erb
+++ b/Support/app/views/config/index.html.erb
@@ -14,23 +14,28 @@
<%
tabindex = 0
[
- ["Name", "user.name", [:global]],
- ["Email", "user.email", [:global]],
+ ["text", "Name", "user.name", [:global]],
+ ["text", "Email", "user.email", [:global]],
[],
- ["Log limit", "git-tmbundle.log.limit", [:global, :local], {:style => "width: 40px"}],
- ["Log context lines", "git-tmbundle.log.context-lines", [:global, :local], {:style => "width: 40px"}],
- ["Show diff check (yes or no)", "git-tmbundle.show-diff-check", [:global, :local], {:style => "width: 40px"}],
+ ["text", "Log limit", "git-tmbundle.log.limit", [:global, :local], {:style => "width: 40px"}],
+ ["text", "Log context lines", "git-tmbundle.log.context-lines", [:global, :local], {:style => "width: 40px"}],
+ ["text", "Show diff check (yes or no)", "git-tmbundle.show-diff-check", [:global, :local], {:style => "width: 40px"}],
[],
- ["Gitnub path", "git-tmbundle.gitnub-path", [:global], {:style => "width: 250px"}],
- ["GitX path", "git-tmbundle.gitx-path", [:global], {:style => "width: 250px"}],
- ].each do |label, key, scopes, input_options|
+ ["select", "External Git App", "git-tmbundle.ext-app", [:global], {
+ :select_options => {:gitgui => "Git Gui", :gitk => "gitk", :gitnub => "Gitnub",
+ :gitx => "GitX", :stree => "SourceTree", :custom => "custom" }
+ }],
+ ["text", "Gitnub path", "git-tmbundle.gitnub-path", [:global], {:style => "width: 250px"}],
+ ["text", "GitX path", "git-tmbundle.gitx-path", [:global], {:style => "width: 250px"}],
+ ["text", "Custom Command", "git-tmbundle.ext-custom-cmd", [:global], {:style => "width: 250px"}],
+ ].each do |type, label, key, scopes, input_options|
%>
<% [:global, :local].each do |scope| %>
- <% if scopes && scopes.include?(scope)
+ <% if scopes && scopes.include?(scope)
tabindex += 1 %>
<%= label %> |
- <%= config_text_field scope, key, {:tabindex => tabindex}.merge(input_options || {}) %> |
+ <%= config_form_field type, scope, key, {:tabindex => tabindex}.merge(input_options || {}) %> |
<% else %>
|
|
@@ -40,6 +45,6 @@
<% end %>
-
+
diff --git a/info.plist b/info.plist
index 2b791b9..765265d 100644
--- a/info.plist
+++ b/info.plist
@@ -39,12 +39,9 @@
0DBC221A-B726-4367-A5E1-04AB999F8CC2
7CE2C842-EBC4-443C-8DDB-3B16AC593D9A
------------------------------------
- 20F5C491-F71C-4963-9C61-DF7294976550
- 1FF5FF82-13A0-4C83-BAD6-D67AE8180FA9
1C12DE42-78A9-4DCA-BB55-2B8E6328C72D
- D0DF4B19-F311-48CC-BF68-F8B33CD051D3
------------------------------------
- 5A08145A-069F-4196-8F32-07C05EF4DCB6
+ 547EFC07-D15D-4217-9695-9043232560FF
------------------------------------
739BCC37-16DE-40BE-83C1-0AE8FDC45036
794C7EF9-B0A5-4B27-90BD-000837237B85
@@ -111,9 +108,6 @@
3E646038-6F79-46BE-96A3-9802E7011162
E6D2DCFE-A40D-4BF1-9B43-7E3199CF00B4
7CE2C842-EBC4-443C-8DDB-3B16AC593D9A
- 20F5C491-F71C-4963-9C61-DF7294976550
- D0DF4B19-F311-48CC-BF68-F8B33CD051D3
- 1FF5FF82-13A0-4C83-BAD6-D67AE8180FA9
246BC5D6-F4DC-458B-8966-C601B65AA1E9
6494E41A-04CE-4D30-BD9A-B50056A7C13F
3F84F9EB-027A-4200-B29B-C99EFA09F453
@@ -130,6 +124,7 @@
0DBC221A-B726-4367-A5E1-04AB999F8CC2
E0901B2E-8953-4A2F-A872-8DBE1A047370
683BF855-9BC9-47A6-89DD-7C2192E62FD7
+ 547EFC07-D15D-4217-9695-9043232560FF
require