tomasbjerre / git-changelog-maven-plugin

Maven plugin that can generate a changelog, or releasenotes, from git repository
Other
80 stars 36 forks source link

Changelog generation between last two tags/refs ? #8

Open laurentperez opened 7 years ago

laurentperez commented 7 years ago

Hi Under jenkins using the git changelog lib, GIT_PREVIOUS_COMMIT / GIT_COMMIT properties can be resolved and passed as from/to references I have a use case where I want to generate the changelog, but outside of jenkins. I'd like to create a changelog between current master and the latest known tag, or between the latest tag and the previous one. I have looked into the code and only found a ZERO_COMMIT reference. It is possible to feed the the maven plugin with command line hashes given https://github.com/tomasbjerre/git-changelog-maven-plugin/blob/master/git-changelog-maven-plugin-example/pom.xml Does anyone have the magic git hashes diff command to get the two hashes usable in this diff scenario ? Thanks

tomasbjerre commented 7 years ago

Should be no problem if you configure the pom like:

<execution>
    <id>GenerateGitChangelogCommits</id>
    <phase>generate-sources</phase>
    <goals>
        <goal>git-changelog</goal>
    </goals>
    <configuration>
        <file>CHANGELOG.md</file>
        <fromRef>${fromRef}</fromRef>
        <toRef>${toRef}</toRef>
    </configuration>
</execution>

And build like

mvn generate-sources -DfromRef=`git describe --abbrev=0 --tags` -DtoRef=master

See also: https://stackoverflow.com/questions/1404796/how-to-get-the-latest-tag-name-in-current-branch-in-git