github-action-get-previous-tag icon indicating copy to clipboard operation
github-action-get-previous-tag copied to clipboard

Action pulls tag associated with latest commit, not the latest tag

Open bakoontz2 opened this issue 2 years ago • 1 comments

(Sorry, the workflow is not accessible publicly)

Two tags of interest, 1.10.109 and 1.10.110. Pulling the timestamps for the associated commits:

image

The timestamps for the tags themselves:

image

Clearly, 1.10.110 was created at a later time than 1.10.109. However, this is what get-previous-tag returns:

image

Interestingly, the timestamp "1662046975" corresponds to the commit time shown in the first image:

image

In the code:

image

"rev-list" "lists commit objects in reverse chronological order" (per the git-rev-list manpage). So the revision that is being returned isn't the revision associated with the latest tag, it's the revision representing the latest commit.

A more accurate command to actually return the lastest tag might be:

git for-each-ref --sort=-taggerdate --format="%(refname:short) | %(taggerdate)" "refs/tags/*"

where the last returned value is, in fact, the latest tag:

image

bakoontz2 avatar Sep 05 '22 19:09 bakoontz2

(Sorry, the workflow is not accessible publicly)

No worries, it's normally useful for easier debugging. But you've made an outstanding case with examples all the way down. The code changes in the PR look good, but for some reason don't output a commit. Will see how they can be updated to fail when that is missing.

WyriHaximus avatar Sep 11 '22 17:09 WyriHaximus