public
Description: The Git TextMate Bundle
Homepage: http://tim.theenchanter.com/
Clone URL: git://github.com/timcharper/git-tmbundle.git
git-tmbundle / Commands / Revert.tmCommand
100644 39 lines (33 sloc) 1.195 kb
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
<?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/ui.rb'
require ENV['TM_SUPPORT_PATH'] + '/lib/escape.rb'
 
git = SCM::Git.new
paths = git.paths(:unique =&gt; true, :fallback =&gt; :current_file)
 
display = paths.map { |e| File.basename(e) }.join("”, “")
plural = (paths.size == 1) ? '' : 's'
files = (paths.size == 1) ? "“#{display}”" : 'files'
 
if 'Revert' == TextMate::UI.alert(:warning, "Revert #{files}?", "Do you really want to revert the file#{plural} “#{display}” and lose all local changes?", 'Revert', 'Cancel')
 
  puts git.revert(paths)
 
  git.rescan_project
end
</string>
  <key>input</key>
  <string>none</string>
  <key>keyEquivalent</key>
  <string>^G</string>
  <key>name</key>
  <string>Revert…</string>
  <key>output</key>
  <string>showAsTooltip</string>
  <key>uuid</key>
  <string>CDEA521C-8963-414F-8F8E-F9B81EF79ADA</string>
</dict>
</plist>