Skip to content

Commit fc32a8a

Browse files
committed
...and sometimes, you won't have the commit...
...because it's not on any of the branches you pulled, just on a synthetic GitHub PR ref.
1 parent b6269f0 commit fc32a8a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

scala-git/src/main/scala/com/madgag/git/package.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ package object git {
226226

227227
def asRevCommit(implicit revWalk: RevWalk) = revWalk.parseCommit(objectId)
228228

229+
def asRevCommitOpt(implicit revWalk: RevWalk): Option[RevCommit] =
230+
if (revWalk.getObjectReader.has(objectId)) Some(objectId.asRevCommit) else None
231+
229232
def asRevTag(implicit revWalk: RevWalk) = revWalk.parseTag(objectId)
230233

231234
def asRevTree(implicit revWalk: RevWalk) = revWalk.parseTree(objectId)

0 commit comments

Comments
 (0)