Skip to content

spotlessSetLicenseHeaderYearsFromGitHistory - Unable to parse date from command - format.pretty #2940

@michakuehn

Description

@michakuehn

If a user has defined a specific git log format (pretty, etc.) in .gitconfig, the date may not be displayed.

The LicenseHeaderStep.java cannot then parse the date and throws an error:

[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:3.4.0:apply (default) on project ...: There were 1 lint error(s), they must be fixed or suppressed.

[ERROR]   src/main/java/.....java:LINE_UNDEFINED com.diffplug.spotless.generic.LicenseHeaderStep(java.lang.IllegalArgumentException) Unable to parse date from command 'git log --follow --find-renames=40% --reverse -- C:\..\..\.....java': (...)

[ERROR]   Resolve these lints or suppress with `<lintSuppressions>`

To make parsing more robust with respect to user configurations, it would be better if the git log command specified the format it expects rather than relying on what the user has configured.

Example: git log --date=format:‘%Y’ --format=%cd

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions