forked from jcf/git-tmbundle
/
Compare Branches.tmCommand
40 lines (35 loc) · 1.34 KB
/
Compare Branches.tmCommand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby
require ENV['TM_BUNDLE_SUPPORT'] + '/environment.rb'
require ENV['TM_SUPPORT_PATH'] + '/lib/osx/plist'
git = Git.new
git_base = File.expand_path('..', git.git_dir(git.paths.first))
branches = git.branch.list(:all)
parameters = { "branches" => branches.map { |e| { "name" => e[:name] } } }
token = open('|"$DIALOG" -a CompareBranches', 'r+') { |io| io << parameters.to_plist; io.close_write; io.read.chomp }
res = open('|"$DIALOG" -w' + token) { |io| OSX::PropertyList.load(io) }
open('|"$DIALOG" -x' + token) { |io| }
if res && res['returnArgument']
parent = res['returnArgument'].first['name']
current = res['currentBranch'].first['name']
dispatch(:controller => "diff", :action => "diff", :branches => [parent, current])
end
</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>^G</string>
<key>name</key>
<string>Compare Branches…</string>
<key>output</key>
<string>showAsHTML</string>
<key>uuid</key>
<string>E56D4990-B615-4788-A46C-5D0CDE750D56</string>
</dict>
</plist>