jgitver-maven-plugin icon indicating copy to clipboard operation
jgitver-maven-plugin copied to clipboard

COMMIT_ISO_TIMESTAMP is empty when the repository is initialized without commits

Open thijsrijpert opened this issue 1 year ago • 0 comments

Issue

version: 1.8.0

usage context:

  • [ ] maven command line:
  • [ ] eclipse:
  • [ ] netbeans:
  • [X] Intellij IDEA: 2024.1.4

Problem description:

jgitver collects a large amount of useful data from git. This includes a field which contains the commit timestamp (COMMIT_ISO_TIMESTAMP). If the repository is initialized, but without commits the timestamp is equal to an empty string.

This can cause hard to diagnose issues in downstream maven plugins, such as https://github.com/apache/maven-compiler-plugin/pull/244.

Steps to reproduce

  1. Create a new maven project, with jgitver installed
  2. Add the ant-run configuration as specified below
  3. Initialize an empty git repository
  4. run: mvn clean install
  5. Observe that the date is an empty string

ant-run:

    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <tasks>
                    <echo>used version: ${jgitver.used_version}</echo>
                    <echo>version calculated: ${jgitver.calculated_version}</echo>
                    <echo>dirty: ${jgitver.dirty}</echo>
                    <echo>head_committer_name: ${jgitver.head_committer_name}</echo>
                    <echo>head_commiter_email: ${jgitver.head_commiter_email}</echo>
                    <echo>head_commit_datetime: ${jgitver.head_commit_datetime}</echo>
                    <echo>git_sha1_full: ${jgitver.git_sha1_full}</echo>
                    <echo>git_sha1_8: ${jgitver.git_sha1_8}</echo>
                    <echo>branch_name: ${jgitver.branch_name}</echo>
                    <echo>head_tags: ${jgitver.head_tags}</echo>
                    <echo>head_annotated_tags: ${jgitver.head_annotated_tags}</echo>
                    <echo>head_lightweight_tags: ${jgitver.head_lightweight_tags}</echo>
                    <echo>base_tag: ${jgitver.base_tag}</echo>
                    <echo>all_tags: ${jgitver.all_tags}</echo>
                    <echo>all_annotated_tags: ${jgitver.all_annotated_tags}</echo>
                    <echo>all_lightweight_tags: ${jgitver.all_lightweight_tags}</echo>
                    <echo>all_version_tags: ${jgitver.all_version_tags}</echo>
                    <echo>all_version_annotated_tags: ${jgitver.all_version_annotated_tags}</echo>
                    <echo>all_version_lightweight_tags: ${jgitver.all_version_lightweight_tags}</echo>
                    <echo>commit_iso_timestamp: ${jgitver.commit_iso_timestamp}</echo>
                </tasks>
            </configuration>
        </execution>
    </executions>
</plugin>```

**Request**

Would it be possible to have log the used values by default, instead of having to use the ant-run plugin? Or to supply a default value for the commit_iso_timestamp when it is empty?

thijsrijpert avatar Jun 28 '24 11:06 thijsrijpert