Class: Gip
- Inherits:
-
Thor
- Object
- Thor
- Gip
- Defined in:
- lib/gip.rb
Defined Under Namespace
Classes: BadCommand, CommandError, Remote
Constant Summary collapse
- VERSION =
"0.2.2"
Instance Method Summary collapse
- #import(repository_url, path = nil) ⇒ Object
- #remotify ⇒ Object
- #update(path = nil) ⇒ Object
- #version ⇒ Object
Instance Method Details
#import(repository_url, path = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gip.rb', line 25 def import(repository_url, path=nil) uri = begin URI.parse(repository_url) rescue URI::InvalidURIError URI.parse("git://" + repository_url.split("@", 2).last.split(":", 2).join("/")) end path = File.basename(uri.path).sub(File.extname(uri.path), "") unless path name = [:remote] name = File.basename(uri.path).sub(File.extname(uri.path), "") unless name remote = Remote.new(name, repository_url, path) commit = extract_commit(remote) puts "Importing #{remote.url} into #{remote.path} at #{commit}" create_remote remote.name, remote.url git :fetch, remote.name git :"read-tree", "--prefix=#{remote.path}/", "-u", commit gipinfo(remote) git :add, ".gipinfo" git :commit, "-m", "Vendored #{repository_url} at #{commit}", :verbose => true end |
#remotify ⇒ Object
51 52 53 54 55 56 |
# File 'lib/gip.rb', line 51 def remotify read_gipinfo.each do |remote| create_remote(remote.name, remote.url) git :fetch, remote.name end end |
#update(path = nil) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/gip.rb', line 64 def update(path=nil) read_gipinfo.each do |remote| next unless remote.path == path commit = extract_commit(remote) puts "Freshening #{remote.path} from #{remote.url} to #{commit}" create_remote remote.name, remote.url git :fetch, remote.name git :merge, "-s", :subtree, "#{remote.name}/#{commit}", :verbose => true end end |
#version ⇒ Object
11 12 13 |
# File 'lib/gip.rb', line 11 def version puts "Gip v#{VERSION}" end |