Class: GitRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/git_repo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, name = nil) ⇒ GitRepo

Returns a new instance of GitRepo.



6
7
8
9
10
# File 'lib/git_repo.rb', line 6

def initialize(path, name = nil)
  @path = path
  @name = name
  @memoize = {}
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/git_repo.rb', line 4

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/git_repo.rb', line 4

def path
  @path
end

Instance Method Details

#latest_local_commitObject



21
22
23
# File 'lib/git_repo.rb', line 21

def latest_local_commit
  run "rev-parse HEAD"
end

#urlObject



12
13
14
15
16
17
18
19
# File 'lib/git_repo.rb', line 12

def url
  url = run("config --get remote.origin.url")
  return if url.blank?

  url.sub!(/\Agit@github\.com:/, "https://github.com/")
  url.sub!(/\.git\z/, "")
  url
end