Class: Gglog::Repository

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Repository

Returns a new instance of Repository.



17
18
19
20
# File 'lib/gglog/repository.rb', line 17

def initialize(path)
  @path = path
  @repo = Rugged::Repository.new(path)
end

Class Method Details

.checkout(clone_url, path) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/gglog/repository.rb', line 8

def checkout(clone_url, path)
  FileUtils.mkdir_p(path)
  Dir.chdir(path) do
    system "git", "clone", "--quiet", clone_url, path
  end
  new(path)
end

Instance Method Details

#commit_messagesObject



26
27
28
29
30
# File 'lib/gglog/repository.rb', line 26

def commit_messages
  commits.map do |commit|
    CommitMessage.new_from_commit_object(commit, name)
  end
end

#nameObject



22
23
24
# File 'lib/gglog/repository.rb', line 22

def name
  File.basename(@path)
end

#pullObject



38
39
40
41
42
43
# File 'lib/gglog/repository.rb', line 38

def pull
  Dir.chdir(@path) do
    system "git", "reset", "--hard", "--quiet"
    system "git", "pull", "--force", "--quiet", "origin", "HEAD"
  end
end

#show(sha) ⇒ Object



32
33
34
35
36
# File 'lib/gglog/repository.rb', line 32

def show(sha)
  Dir.chdir(@path) do
    system "git", "show", sha
  end
end