Skip to content

Commit

Permalink
refactor: simplify counting local commits with library function
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesRudolph committed Jun 21, 2024
1 parent 6963037 commit b149027
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,10 @@ open class GitHandlerService(

fun hasLocalCommits(): Boolean {
val origin = git.repository.resolve("origin/${gitConfig.remoteBranch}")
val head = git.getRepository().resolve("HEAD")
val head = git.repository.resolve("HEAD")

var count = 0
for (entry in git.log().addRange(origin, head).call()) {
++count
}
val range = git.log().addRange(origin, head).call()
val count = range.count()

if (count > 0) {
log.info { "Your branch is ahead of 'origin/${gitConfig.remoteBranch}' by $count commit(s)." }
Expand Down

0 comments on commit b149027

Please sign in to comment.