Class: Bob::Test::GitRepo
Instance Method Summary
collapse
#add_commit, #add_failing_commit, #add_successful_commit, #command, #initialize, #script, #short_head
Instance Method Details
#add(file) ⇒ Object
71
72
73
|
# File 'lib/bob/test/repo.rb', line 71
def add(file)
`git add #{file}`
end
|
#branch ⇒ Object
63
64
65
|
# File 'lib/bob/test/repo.rb', line 63
def branch
"master"
end
|
#commit(message) ⇒ Object
75
76
77
|
# File 'lib/bob/test/repo.rb', line 75
def commit(message)
`git commit -m "#{message}"`
end
|
#commits ⇒ Object
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/bob/test/repo.rb', line 95
def commits
Dir.chdir(@path) {
`git log --pretty=oneline`.collect { |l| l.split(" ").first }.
inject([]) { |acc, sha1|
fmt = "---%nmessage: >-%n %s%ntimestamp: %ci%n" \
"id: %H%nauthor: %n name: %an%n email: %ae%n"
acc << YAML.load(`git show -s --pretty=format:"#{fmt}" #{sha1}`)
}.reverse
}
end
|
#create ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/bob/test/repo.rb', line 83
def create
FileUtils.mkdir(@path)
Dir.chdir(@path) {
`git init`
`git config user.name 'John Doe'`
`git config user.email '[email protected]'`
}
super
end
|
#head ⇒ Object
79
80
81
|
# File 'lib/bob/test/repo.rb', line 79
def head
Dir.chdir(@path) { `git log --pretty=format:%H | head -1`.chomp }
end
|
#scm ⇒ Object
59
60
61
|
# File 'lib/bob/test/repo.rb', line 59
def scm
"git"
end
|
#uri ⇒ Object
67
68
69
|
# File 'lib/bob/test/repo.rb', line 67
def uri
@path
end
|