class Commit
Public Class Methods
from(identifier: String)
click to toggle source
# 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()
click to toggle source
# File lib/branch_cli/commit.rb, line 10 def self.getCurrentHead return Commit.from(identifier: "HEAD") end
new(message: String, sha: String)
click to toggle source
# File lib/branch_cli/commit.rb, line 5 def initialize(message: String, sha: String) self.message = message.clearQuotes self.sha = sha.clearQuotes end
Private Class Methods
message(identifier: String)
click to toggle source
# File lib/branch_cli/commit.rb, line 52 def self.message(identifier: String) return runCommand("git log -1 #{identifier} --format=\"%s\"").stdout end
sha(identifier: String)
click to toggle source
# File lib/branch_cli/commit.rb, line 48 def self.sha(identifier: String) return runCommand("git log -1 #{identifier} --format=\"%H\"").stdout end
Public Instance Methods
commitsLeading(commit: Commit)
click to toggle source
# 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 = [] # [Commit] let shas = run.components(separatedBy: "\n") shas.each do |sha| commits.append(Commit.from(identifier: sha)) end return commits end
mostRecentCommonAncestor(commit: Commit)
click to toggle source
# 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
printableFormat(format)
click to toggle source
# 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