Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitCommitDate is author date rather than commit date #827

Closed
KalleOlaviNiemitalo opened this issue Sep 30, 2022 · 3 comments · Fixed by #1103
Closed

GitCommitDate is author date rather than commit date #827

KalleOlaviNiemitalo opened this issue Sep 30, 2022 · 3 comments · Fixed by #1103

Comments

@KalleOlaviNiemitalo
Copy link

KalleOlaviNiemitalo commented Sep 30, 2022

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);

@KalleOlaviNiemitalo
Copy link
Author

The GitCommitDateTicks property for MSBuild has used the author date ever since it was added in #329 for the feature request #328. Neither of those has any comments on author date vs. commit date.

@qmfrederik, did your scenario need specifically the author date?

@AArnott
Copy link
Collaborator

AArnott commented Oct 2, 2022

I'm ok with changing the code to retrieve the commit date instead. If someone needs the author date, we should add that as another property. Care to send a PR?

@KalleOlaviNiemitalo
Copy link
Author

KalleOlaviNiemitalo commented Oct 4, 2022

I don't have a Windows instance on which I could install VS2019, so won't make a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants