al3x (owner)

Revisions

gist: 95942 Download_button fork
public
Description:
Brute force update of TextMate bundles, be they from Git or Subversion
Public Clone URL: git://gist.github.com/95942.git
bundleup.rb
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
#!/usr/bin/env ruby
 
require 'fileutils'
 
ENV['LC_ALL'] = nil
ENV['LC_CTYPE'] = 'en_US.UTF-8'
 
DEBUG = false
 
bundle_dir = "#{ENV['HOME']}/Library/Application\ Support/TextMate/Bundles"
pristine_bundle_dir = "#{ENV['HOME']}/Library/Application\ Support/TextMate/Pristine\ Copy/Bundles"
dirs = [bundle_dir, pristine_bundle_dir]
 
def update_repos_in_dir(dir, topdir)
  return if dir =~ /^\.+/
  return if dir =~ /^\.DS_Store/
 
  Dir.chdir(dir)
  pwd = FileUtils.pwd
  entries = Dir.entries('.')
 
  if entries.include?('.svn')
    puts "found svn in #{pwd}"
    puts `svn up`
    puts
  elsif entries.include?('.git')
    puts "found git in #{pwd}"
    puts `git pull`
    puts
  elsif DEBUG
    puts "no repo in #{pwd}"
  end
 
  Dir.chdir('..')
end
 
dirs.each do |dir|
  Dir.chdir(dir)
 
  Dir.entries('.').each do |entry|
    next if dir =~ /^\.+/
    next unless File.directory?(dir)
 
    update_repos_in_dir(entry, dir)
  end
end
 
`osascript -e 'tell app "TextMate" to reload bundles'`
 
puts "bundles reloaded. done."