Module: Flux::Git

Defined in:
lib/flux/git.rb

Defined Under Namespace

Classes: Branch

Class Method Summary collapse

Class Method Details

.Branch(branch, repo_path = Git.repo_path) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/flux/git.rb', line 18

def self.Branch(branch, repo_path = Git.repo_path)
  case branch
  when Branch
    branch
  when String
    remotes = Git.repo(repo_path).remote_list

    if remotes.find { |r| branch =~ %r{^#{r}/} }
      args = branch.split('/', 2).reverse << repo_path

      Branch.remote(*args)
    else
      Branch.local(branch, repo_path)
    end
  else
    raise "Unable to convert object to branch: #{branch.inspect}"
  end
end

.git(path = repo_path) ⇒ Object



5
6
7
# File 'lib/flux/git.rb', line 5

def self.git(path = repo_path)
  Grit::Git.new(path)
end

.repo(path = repo_path) ⇒ Object



9
10
11
# File 'lib/flux/git.rb', line 9

def self.repo(path = repo_path)
  Grit::Repo.new(path)
end

.repo_path(start_dir = Dir.pwd) ⇒ Object



13
14
15
16
# File 'lib/flux/git.rb', line 13

def self.repo_path(start_dir = Dir.pwd)
  Flux.find_upwards('.git', start_dir) or
    raise RCSError, "Couldn't find git repo starting at #{start_dir}."
end