#913970 uscan: git mode: last tag not taken into account

Package:
devscripts
Source:
devscripts
Description:
scripts to make the life of a Debian Package maintainer easier
Submitter:
Alexandre Viau
Date:
2025-01-24 15:51:02 UTC
Severity:
wishlist
Tags:
#913970#5
Date:
2018-11-17 18:19:38 UTC
From:
To:
When using uscan's git mode on a repository that has tags, uscan does
not take into account the last tag when constructing the version number.

For example, if a repository has a v0.3.0 tag and commits were done
after the tag, the last commit being done on 2018-10-25 and having the
hash f80706d, the version should be:
 - 0.3.0~git20181025.f80706d

However, uscan currently reports the following version:
 - 0.0~git20181025.f80706d

My watch file is like so:
```
version=4
opts=mode=git, \
https://github.com/collectd/go-collectd.git \
HEAD
```

The specs for the git mode were originally discussed in #811565. It
might be that this part of the spec was simply not implemented yet, so
feel free to change the severity to wishlist.

Cheers,

#913970#10
Date:
2018-11-17 19:07:21 UTC
From:
To:
Le 17/11/2018 à 19:19, Alexandre Viau a écrit :

Hello,

I'll take a look. For now, you can use "pretty":

version=4
opts="pretty=0.3.0~git%cd.%h,mode=git,pgpmode=none" \
https://github.com/collectd/go-collectd.git \
 HEAD

#913970#13
Date:
2018-11-17 21:20:56 UTC
From:
To:
Even if they were discussed there, changing such detail would be a
breaking change now, so I think it would be hard to do "by default".

I think what you are saying is that git HEAD tracking always uses
0.0~ instead of using a version like the one used by `git describe`?  In
that case, skimming through #811565 it seems to me that it was
purposefully left out, so at most adding it now it could/should be done
with an option.

#913970#18
Date:
2018-11-18 00:14:17 UTC
From:
To:
Thanks!

Sure, that helps in the meantime.

#913970#23
Date:
2018-11-18 00:23:01 UTC
From:
To:
That would be unfortunate as I think this is a much better default and
it was suggested from the start.

However it that must be added as an option then sure, it will be better
than not having it at all.

Yes.

#913970#28
Date:
2018-11-18 08:42:30 UTC
From:
To:
Le 18/11/2018 à 01:23, Alexandre Viau a écrit :

Hi all,

I added a @TAG@ macro for this to avoid regression
(https://salsa.debian.org/debian/devscripts/merge_requests/85)

Your debian/watch becomes:

  version=4
  opts="pretty=@TAG@+git%cd.%h,mode=git,pgpmode=none" \
https://github.com/collectd/go-collectd.git \
  HEAD

Cheers,
Xavier

#913970#33
Date:
2018-11-18 09:50:03 UTC
From:
To:
Le 17/11/2018 à 22:20, Mattia Rizzolo a écrit :

Yes, until now "pretty" option is given directly to `git log
--pretty=format:$pretty` which has no option to get last tag.

Done with a macro to allow DD to customize their "pretty"

#913970#38
Date:
2019-01-12 18:23:44 UTC
From:
To:
Control: tag -1 + patch - pending
Control: severity -1 wishlist

I don't particularly like that @TAG@ thing atm.

The patch is available in that MR for the future, in case I change my
mind, but I think the current set of features is so messy already that
it's already quite hard to follow.  Manually changing the version in
there is not that much of an hassle for now anyway.

#913970#49
Date:
2025-01-24 15:47:28 UTC
From:
To:
tl;dr please support uversionmangle after pretty=

We have a few reasonably common variations of combined tag and date
versions in debian, sometimes including the hash. From discussing in
#debian-mentors this is currently only possible in two ways:

* pretty=1.2.3+%cd.%h (e.g. libretro-nestopia)
  as suggested above by yadd, but hardcoded and will miss newer tags
* dversionmangle=s/\+git\d+$// (e.g. cegui-mk2)
  maintainer manually downloads snapshot and appends date to d/changelog

Since git 2.35 (bullseye-backports) this pretty syntax is possible, and
works today in uscan but has some drawbacks:

    opts="mode=git, gitmode=full, pretty=%(describe:abbrev=0)+%cd"

It results in a string like "version-0.4.4+20241227" and for some reason
uversionmangle=s/version-// has no effect. It also only works on
Annotated tags, "describe:tags=true,abbrev=0" should fix that, but opts=
comma parsing splits it first and I can't find a way to escape it. So I
think that if uversionmangle worked then "describe:tags=true" would be
fine and the abbrev=0 could be replicated with sed.

#913970#52
Date:
2025-01-24 15:47:28 UTC
From:
To:
tl;dr please support uversionmangle after pretty=

We have a few reasonably common variations of combined tag and date
versions in debian, sometimes including the hash. From discussing in
#debian-mentors this is currently only possible in two ways:

* pretty=1.2.3+%cd.%h (e.g. libretro-nestopia)
  as suggested above by yadd, but hardcoded and will miss newer tags
* dversionmangle=s/\+git\d+$// (e.g. cegui-mk2)
  maintainer manually downloads snapshot and appends date to d/changelog

Since git 2.35 (bullseye-backports) this pretty syntax is possible, and
works today in uscan but has some drawbacks:

    opts="mode=git, gitmode=full, pretty=%(describe:abbrev=0)+%cd"

It results in a string like "version-0.4.4+20241227" and for some reason
uversionmangle=s/version-// has no effect. It also only works on
Annotated tags, "describe:tags=true,abbrev=0" should fix that, but opts=
comma parsing splits it first and I can't find a way to escape it. So I
think that if uversionmangle worked then "describe:tags=true" would be
fine and the abbrev=0 could be replicated with sed.