class OpenRemote
universal version tracking
Constants
- Help
large constant strings
- Version
Public Instance Methods
no_repo?()
click to toggle source
# File lib/open-remote.rb, line 37 def no_repo? `git status 2>&1`.split("\n").first == "fatal: Not a git repository (or any of the parent directories): .git" end
remote(search = /.*/)
click to toggle source
# File lib/open-remote.rb, line 42 def remote(search = /.*/) if no_repo? puts "Not currently in a git repository.".red exit 1 end remote_site = remotes.find { |r| r.each_value.any? { |d| d.downcase.match search } } if remote_site.nil? puts "No remotes found that match #{search.to_s.red}. All remotes:\n" + remotes.join("\n") exit 1 else remote_site[:url] end end
remotes()
click to toggle source
# File lib/open-remote.rb, line 59 def remotes %x{git remote -v}.split("\n").map {|r| { :remote => r.split[0], :url => r.split[1], }}.uniq end
run(args)
click to toggle source
# File lib/open-remote.rb, line 10 def run(args) arg = args.shift case arg when nil # open first remote Browser.browse remote when "--help", "-h" puts OpenRemote::Help when "--version", "-v" puts OpenRemote::Version when "--alias" system "git config --global alias.open '!open-remote'" when "--unalias" system "git config --global --unset alias.open" when "--output", "-o" puts Browser.prepare remote else # check against remotes Browser.browse remote(arg) end end