Search code examples
gitgradlegroovygrgitgradle-git

Using grgit to capture logs between two tags


I want to capture the commit messages between two tags. Like, I create a tag in my repo, then commit some files and then add a tag. So, in between these tags, I want to capture those commit messages. All this is suppose to be done using grgit, the gradle git plugin :

Currently, I can see the logs by using the log operation of grgit plugin like this:

def log = grgit.log()

log.each { l ->
    logger.lifecycle("ID: $l.id, Author: $l.author, FullMessage: $l.fullMessage")
}

Now, the above method gives me an entire list of logs but I just want between two tags.I am sure, in order to see the logs between two tags, I will have to apply a for loop in place of each and give starting point as tagA and end point as tagB. But I am not so sure how to achieve that correctly. Any pointers!


Solution

  • Per the documentation of Grgit for the log operation, you could do something like this:

    def log = grgit.log {
      range 'tagA', 'tagB'
    }