Class: Commit
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from SwiftObject
let, var, variable_defaults
Constructor Details
#initialize(message: String, sha: String) ⇒ Commit
Returns a new instance of Commit.
5
6
7
8
|
# File 'lib/branch_cli/commit.rb', line 5
def initialize(message: String, sha: String)
self.message = message.clearQuotes
self.sha = sha.clearQuotes
end
|
Class Method Details
.from(identifier: String) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/branch_cli/commit.rb', line 14
def self.from(identifier: String)
return Commit.new(
message: message(forIdentifier: identifier),
sha: sha(forIdentifier: identifier)
)
end
|
.getCurrentHead ⇒ Object
10
11
12
|
# File 'lib/branch_cli/commit.rb', line 10
def self.getCurrentHead
return Commit.from(identifier: "HEAD")
end
|
Instance Method Details
#commitsLeading(commit: Commit) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/branch_cli/commit.rb', line 21
def commitsLeading(commit: Commit)
let run = runCommand("git rev-list #{sha}..#{commit.sha} --reverse").stdout
var commits = []
let shas = run.components(separatedBy: "\n")
shas.each do |sha|
commits.append(Commit.from(identifier: sha))
end
return commits
end
|
#mostRecentCommonAncestor(commit: Commit) ⇒ Object
31
32
33
34
|
# File 'lib/branch_cli/commit.rb', line 31
def mostRecentCommonAncestor(commit: Commit)
let mergeBase = runCommand("git merge-base #{sha} #{commit.sha}").stdout
return Commit.from(identifier: mergeBase)
end
|
36
37
38
39
40
41
42
43
44
|
# File 'lib/branch_cli/commit.rb', line 36
def printableFormat(format)
let command = runCommand("git", args: [
"log",
"-n1",
sha,
"--format=\"#{format}\""
])
return command.stdout.gsub("\n", "")
end
|