Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

History plugin not parsing date correctly #258

Closed
danmetzler opened this issue Jan 11, 2022 · 6 comments
Closed

History plugin not parsing date correctly #258

danmetzler opened this issue Jan 11, 2022 · 6 comments

Comments

@danmetzler
Copy link
Contributor

danmetzler commented Jan 11, 2022

I'm using Git version 2.34.1, and seem to be getting errors in the History plugin.

Appears the issue is here. (line 35)

For me the date is at index 3 instead of index 2.

Since my setup is new, I'm not sure if this is an issue specific to my git config, or more tied to the version of Git, or something that is more widely experienced. (I think it has never worked for me, but maybe others have different experience?)

@danmetzler
Copy link
Contributor Author

danmetzler commented Jan 11, 2022

One way to check if the issue exists on a system:

$log = git --no-pager log -q --grep '^AU: ' --date iso --all | out-string
$all_commits = $log | Select-String 'commit(.|\n)+?(?=\ncommit )' -AllMatches
$ind = 0
foreach ($commit in $all_commits.Matches.Value) {
     $commit = $commit -split '\n'
     $date     = $commit[2].Replace('Date:','').Trim()
     "Index: $ind, Date: $date"
     $ind++
 }

If a non-date shows up for the date, the issue is there.

@danmetzler
Copy link
Contributor Author

danmetzler commented Jan 12, 2022

On further investigation this happens with a merge commit. In that scenario, the next line after the commit line is of the format Merge: <ref> <ref>. Then author and date are shifted down one to the 3rd and 4th lines. This is because I did some work in another branch, and then merged into the main branch.

@majkinetor
Copy link
Owner

Ah, that must be it, we don't have merges with described AppVeyor system so that setup was never taken into consideration.

@danmetzler
Copy link
Contributor Author

It seems to me there are a couple of approaches we could take to fix:

  • We could assume that this is a really rare thing, (I think that's true), and allow the History plugin to generate a bad entry for that commit. Maybe the date shows "(could not be parsed)", and the packages are are something similar. (This just keeps it from erroring.) Or,
  • We could assume that this merge commit is the problem where this would occur, but try to make the History plugin "do the right thing", and handle the merge commit appropriately. (I think the right thing is probably ignore merge commits, even if they contain an "^AU" line in them.)

If we want to do the second option, I think we could look at the commit line that normally contains "Date:" and if it doesn't contain "Date:" then assume it is a merge commit and don't include it.

Any thoughts?

@majkinetor
Copy link
Owner

Lets just add --no-merges param to git log and call it a day.

@danmetzler
Copy link
Contributor Author

Lets just add --no-merges param to git log and call it a day.

Perfect!

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

No branches or pull requests

2 participants