From 2e94095e0cd0ef7fc421c59d9940801111c0aa39 Mon Sep 17 00:00:00 2001 From: Andrei Rybak Date: Thu, 10 Aug 2023 22:52:06 +0200 Subject: [PATCH] CopyCommitReference: use authorTime of commits As per documentation of 'git log': reference (, ) This format is used to refer to another commit in a commit message and is the same as --pretty='format:%C(auto)%h (%s, %ad)'. By default, the date is formatted with --date=short unless another --date option is explicitly specified. As with any format: with format placeholders, its output is not affected by other options like --decorate and --walk-reflogs. the format 'reference' specifically shows the "author date" of a commit, as opposed to "commit date".[1] By default 'git log' shows the author date, and that's why 'reference' format uses the author date as well. Function `commitReference` in CopyCommitReference.kt uses method getTimestamp of interface com.intellij.vcs.log.graph.GraphCommit via intrerface com.intellij.vcs.log.VcsCommitMetadata. All implementations of this interface use commit date for the timestamp, which means that the plugin can produce misleading dates in the references. Use method `getAuthorTime` of com.intellij.vcs.log.VcsShortCommitDetails to include the correct date in the references produced by the plugin. [1] These dates can be different, for example, if a commit is cherry-picked a week after it had been authored, i.e. created. --- CHANGELOG.md | 1 + .../intellij/copy_commit_reference/CopyCommitReference.kt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a670c59..ded843f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ## [Unreleased] ### Fixed +- The plugin sometimes produced references with a slightly incorrect date, which has been corrected. - Incorrect usage of background thread has been fixed to reduce probability of concurrency issues in context menu of annotations. ## [1.1.0] - 2023-07-30 diff --git a/src/main/kotlin/dev/andrybak/intellij/copy_commit_reference/CopyCommitReference.kt b/src/main/kotlin/dev/andrybak/intellij/copy_commit_reference/CopyCommitReference.kt index b063b5b..9b49d15 100644 --- a/src/main/kotlin/dev/andrybak/intellij/copy_commit_reference/CopyCommitReference.kt +++ b/src/main/kotlin/dev/andrybak/intellij/copy_commit_reference/CopyCommitReference.kt @@ -20,7 +20,7 @@ fun copyCommitReference(project: Project, listOfMetadata: List