module GitFyncy::Repo
Constants
- DEFAULT_REMOTE
- GIT_CONFIG
- SCP_REGEX
- SSH_URL_REGEX
- TRAILING_GIT_REGEX
Public Class Methods
get_stdout_str(cmd)
click to toggle source
# File lib/git-fyncy/repo.rb, line 12 def self.get_stdout_str(cmd) out = `#{cmd}`.chomp out.empty? ? nil : out end
git_aware_files()
click to toggle source
# File lib/git-fyncy/repo.rb, line 120 def self.git_aware_files `git ls-files -cmo --exclude-standard`.split("\n") end
host_and_path_for_remote(remote_name)
click to toggle source
# File lib/git-fyncy/repo.rb, line 75 def self.host_and_path_for_remote(remote_name) url = lookup_remote_url remote_name return unless url host_and_path_from_url url end
host_and_path_from_current_repo()
click to toggle source
# File lib/git-fyncy/repo.rb, line 107 def self.host_and_path_from_current_repo # Determine remote fyncy should use url = url_from_config return host_and_path_from_url url if url remote_name = remote_name_from_config remote_name = prompt_user_for_remote_name if STDIN.tty? && !remote_name res = nil res = host_and_path_for_remote remote_name if remote_name res = host_and_path_for_remote DEFAULT_REMOTE unless res res end
host_and_path_from_url(url)
click to toggle source
# File lib/git-fyncy/repo.rb, line 47 def self.host_and_path_from_url(url) md = SSH_URL_REGEX.match url user = nil host = nil remote = nil path = url if md user = md[1] host = md[2] port = md[3] if port && port[1..-1].to_i != 22 STDERR.puts "WARNING: git-fyncy does not currently support port numbers in remote names. Yeah, it is lame. Sorry. Please contribute to fix this!" end path = md[4] else md = SCP_REGEX.match url if md user = md[1] host = md[2] path = slashify remove_trailing_git md[3] end end remote = "#{user}#{host}" if host [remote, path] end
lookup_remote_url(remote_name)
click to toggle source
# File lib/git-fyncy/repo.rb, line 30 def self.lookup_remote_url(remote_name) get_stdout_str "git config --get remote.#{remote_name}.url" end
prompt_user_for_remote_name()
click to toggle source
# File lib/git-fyncy/repo.rb, line 81 def self.prompt_user_for_remote_name prompt = <<-EOS No remote configured. git fyncy looks under the fyncy section of your git config for a remote name or a url (i.e. at fyncy.remote and fyncy.url). If a remote name is specified, that remote's url will be used with the ".git" suffix removed if it exists. Enter a remote name to use (or press return to use #{DEFAULT_REMOTE}): EOS print prompt.chomp remote_name = STDIN.gets.chomp remote_name = DEFAULT_REMOTE if remote_name.empty? if remote_defined?(remote_name) puts else pexit "A remote by the name of \"#{remote_name}\" is not defined in this repo." end if configure_fyncy_remote_name remote_name remote_name else pexit "Failed to set #{GIT_CONFIG.fetch(:remote_name)} to #{remote_name}." end end
remote_defined?(remote_name)
click to toggle source
# File lib/git-fyncy/repo.rb, line 34 def self.remote_defined?(remote_name) system "git config --get remote.#{remote_name}.url" end
remove_trailing_git(str)
click to toggle source
# File lib/git-fyncy/repo.rb, line 39 def self.remove_trailing_git(str) md = TRAILING_GIT_REGEX.match str md ? md[1] : str end