lib/spoom/context/git.rb in spoom-1.2.2 vs lib/spoom/context/git.rb in spoom-1.2.3
- old
+ new
@@ -11,11 +11,11 @@
# Parse a line formated as `%h %at` into a `Commit`
sig { params(string: String).returns(T.nilable(Commit)) }
def parse_line(string)
sha, epoch = string.split(" ", 2)
- return nil unless sha && epoch
+ return unless sha && epoch
time = Time.strptime(epoch, "%s")
Commit.new(sha: sha, time: time)
end
end
@@ -86,11 +86,11 @@
# Get the current git branch in this context directory
sig { returns(T.nilable(String)) }
def git_current_branch
res = git("branch --show-current")
- return nil unless res.status
+ return unless res.status
res.out.strip
end
# Run `git diff` in this context directory
@@ -101,13 +101,13 @@
# Get the last commit in the currently checked out branch
sig { params(short_sha: T::Boolean).returns(T.nilable(Spoom::Git::Commit)) }
def git_last_commit(short_sha: true)
res = git_log("HEAD --format='%#{short_sha ? "h" : "H"} %at' -1")
- return nil unless res.status
+ return unless res.status
out = res.out.strip
- return nil if out.empty?
+ return if out.empty?
Spoom::Git::Commit.parse_line(out)
end
sig { params(arg: String).returns(ExecResult) }