#15 add git_release macro
Merged by clime. Opened by clime.
git_release  into  master

Download 15.patch

Hello, this PR implements git_release macro to be used in spec files to dynamically generate release number from git (annotated) tags.

Release number from the latest tag is taken as a base and dynamic suffixes are appended to it indicating number of commits from the latest tag, HEAD commit short hash, and working tree dirtiness status (.wtree.<timestamp> suffix).

If currently checked out commit is the one tagged most recently and working tree is clean, then no dynamic suffixes are appended and we simply get the value read from the tag (the value after the last dash in the tag name). It may or may not be a number (but assumption is that it will usually be a number).

If rpkg tag is called, then git_release macro generates a "bumped release", which is the release value from the latest tag +1. If bumping is not possible (because release in the latest tag is not a number), then error is raised and manual tag creation is required.

Release resetting may be done by creating a new tag manually with release value equal to 1, example: rpkg tag pkgname-1.1-1 (this is assuming there is e.g. already existing tag pkgname-1.0-3).

git_release can be used together with git_changelog to get also changelogs generated from the tags.

git_release can be technically used with git_version together but the usage probably does not make too much sense. git_version is primarily intended for upstream devels (who will have static Release) and git_release is intended for downstream devels (who will have static Version).

@ngompa @bkabrda: can you, please, review

rev-list --count

why is it release and not version?

Hello Igor! I used | wc -l to count the commits because of compatiblity with git 1.8.

why is it release and not version?

There is git_version macro as well. which is very similar to git_release. The difference is that git_version reads version number (it actually reads only minor part of it) from the latest tag whereas git_release reads the release number (the string after the last dash).

git_version has two (without suffixes) components: major, minor (lead and follow in rpkg naming) and git_release has only one (called pivot in rpkg).

But those macros are very similar. Only difference is that version has a little bit more richer structure.

The code looks good in general, though I want to test it out a bit before signing off on it. Is there a way for me to do so easily?

The code looks good in general, though I want to test it out a bit before signing off on it. Is there a way for me to do so easily?

Hello Neal!

I made Fedora builds here: https://copr.fedorainfracloud.org/coprs/clime/rpkg-util-git-release/

So

dnf install dnf-plugins-core
dnf copr enable clime/rpkg-util-git-release 
dnf install rpkg

Then you can git clone https://pagure.io/rpkg-util

and play around with the built rpkg on the rpkg sources themselves.

I need to make it work from sources directly (without any building/installing).

The easiest way to try the new macro is to place

{{{ git_release }}}

tag somewhere into a spec file (e.g. rpkg-util.spec.rpkg).

Then you can e.g. call rpkg spec to render the whole spec.

If you have Release: {{{ git_release }}} in a spec file, you will see it is taking effect when you call just rpkg -q verrel.

Reading the description of the change and skimming through the code doesn't reveal any issues to me. I'm a bit busy right now so I can't do thorough testing,

@ngompa hello, are you going to continue the review? Do you want me to rebuild/rebase?

Yeah, could you please do a rebuild+rebase?

Yeah, could you please do a rebuild+rebase?

sure.

rebased onto 71ea95a00fe3785d6a4ec1721b5c9575c31a09ad

rebased onto 71ea95a00fe3785d6a4ec1721b5c9575c31a09ad

Rebased and the latest builds are to be found at https://copr.fedorainfracloud.org/coprs/clime/rpkg-util-git-release

For some reason, copr-frontend did not capture updates in this PR to do a PR auto-rebuild. Otherwise, I would be providing builds through that mechanism but builds in https://copr.fedorainfracloud.org/coprs/clime/rpkg-util-git-release should be good as well.

@ngompa do you think I can merge this already? Did you find any issues?

@ngompa Thank you for the initial review.

Pull-Request has been merged by clime

This PR has been migrated to GitHub as a placeholder issue:
https://github.com/fedora-copr/rpkg-util/issues/15

Metadata