Skip to content

GitCommitDate is author date rather than commit date #827

@KalleOlaviNiemitalo

Description

@KalleOlaviNiemitalo

The value of the MSBuild property $(GitCommitDateTicks) comes from the Git author date, even though the name and API documentation indicate that it should come from the Git commit date. The commit date would be more useful in our workflow in which we often cherry-pick commits that are several months old. If the commit date is old, then it is easy to know for sure that the deployed version cannot include any changes that were implemented after that date. The author date cannot be used for this purpose.

Reproduced with Nerdbank.GitVersioning 3.4.240, but the code looks like it works like that in v3.5.113 too:

public override DateTimeOffset? GitCommitDate => this.Commit?.Author.When;

public override DateTimeOffset? GitCommitDate => this.Commit is { } commit ? (commit.Author?.Date ?? this.Repository.GetCommit(commit.Sha, readAuthor: true).Author?.Date) : null;

Assert.Equal(this.LibGit2Repository.Head.Tip.Author.When, this.Context.GitCommitDate);

Metadata

Metadata

Assignees

No one assigned

    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