Class: Bob::Test::GitRepo
Instance Attribute Summary
#name, #path
Instance Method Summary
collapse
#add_commit, #add_failing_commit, #add_successful_commit, #initialize
Instance Method Details
#commits ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/bob/test/scm/git.rb', line 18
def commits
Dir.chdir(path) do
commits = `git log --pretty=oneline`.collect { |l| l.split(" ").first }
commits.inject([]) do |commits, sha1|
format = "---%nmessage: >-%n %s%ntimestamp: %ci%n" +
"identifier: %H%nauthor: %n name: %an%n email: %ae%n"
commits << YAML.load(`git show -s --pretty=format:"#{format}" #{sha1}`)
end.reverse
end
end
|
#create ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/bob/test/scm/git.rb', line 5
def create
FileUtils.mkdir(path)
Dir.chdir(path) do
run "git init"
run "git config user.name 'John Doe'"
run "git config user.email '[email protected]'"
run "echo 'just a test repo' >> README"
add "README"
commit "First commit"
end
end
|
#head ⇒ Object
29
30
31
32
33
|
# File 'lib/bob/test/scm/git.rb', line 29
def head
Dir.chdir(path) do
`git log --pretty=format:%H | head -1`.chomp
end
end
|
#short_head ⇒ Object
35
36
37
|
# File 'lib/bob/test/scm/git.rb', line 35
def short_head
head[0..6]
end
|