This repository has been archived by the owner on Mar 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Git Resolve Conflicts.tmCommand
73 lines (60 loc) · 1.89 KB
/
Git Resolve Conflicts.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?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
# Resolve conflicts command for git/FileMerge
# By Tim Harper
# http://code.leadmediapartners.com/
require "fileutils"
FM="/Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge"
require ENV['TM_BUNDLE_SUPPORT'] + '/environment.rb'
require ENV['TM_SUPPORT_PATH'] + '/lib/escape.rb'
state = :both
input_file_path = ENV['TM_FILEPATH']
input_filename = File.basename(input_file_path)
input = $<.read
left = ""
right = ""
input.each { |line|
if /^(<{7}|={7}|>{7})($| )/.match(line)
state =
case $1
when "<<<<<<<" then :left
when "=======" then :right
when ">>>>>>>" then :both
end
next
end
left << line if state == :left || state == :both
right << line if state == :right || state == :both
}
if left==right
puts "No conflicts to resolve in #{input_file_path}."
exit
end
filename = "git-conflict-resolve"
tmp_path = "/tmp/git-conflict-resolve/"
FileUtils.rm_rf(tmp_path)
FileUtils.mkdir_p(tmp_path)
left_file = "#{tmp_path}left-#{input_filename}.rb"
right_file = "#{tmp_path}right-#{input_filename}.rb"
File.open(left_file, "w") { |f| f.puts left }
File.open(right_file, "w") { |f| f.puts right }
%x{#{FM} -left #{e_sh left_file} -right #{e_sh right_file} -merge #{e_sh input_file_path} &>/dev/null & }
</string>
<key>input</key>
<string>document</string>
<key>keyEquivalent</key>
<string>^G</string>
<key>name</key>
<string>Edit Conflicts With FileMerge…</string>
<key>output</key>
<string>showAsTooltip</string>
<key>uuid</key>
<string>7CE2C842-EBC4-443C-8DDB-3B16AC593D9A</string>
</dict>
</plist>