On Wed, Jan 09, 2013 at 08:38:55PM +0200, Gabor Szabo wrote:
> On Wed, Jan 9, 2013 at 5:17 PM, Lutz Gehlen <lrg...@gmx.net> wrote:
> > Hi Gabor,
> >
> > On Tuesday, January 08, 2013 09:04:31 Gabor Szabo wrote:
> >> I just wanted to update a distribution and ensure that all the
> >> modules in a distribution have
> >> version number and they are all the same.
> >
> > Please excuse this digression, but would you be so kind to explain
> > why you find this desirable? In my distributions, I deliberately
> > only bump the version number of a module to the current value of the
> > distribution when I modify the module. Like that I can easily see
> > when I last modified a certain module.
> 
> I think you strategy - updating the version numbers only when they change -
> might be better, but I am too lazy for that, and I am afraid I'll
> forget to do it.
> If you know a tool that can ensure this, I'd be happy to hear about it.

A first step, from the command-line:

    V=`git describe --abbrev=0`..;git diff-tree -r $V|cut -f2|xargs -IF sh -c 
"git blame $V -- F|grep -q '^[^^].*\$VERSION'&&echo +F||echo =F"

As a git alias:

   checkversion = "!f(){ V=`git describe --abbrev=0`..;git diff-tree -r $V|cut 
-f2|xargs -IF sh -c \"git blame $V -- F|grep -q '^[^^].*\\$VERSION'&&echo 
+F||echo =F\";};f"

(Adapted from http://twitter.com/clunk_eth/status/203966679091384321)

This:
- picks the closest tag from the current commit
- makes a diff of the tree between that tag and the current commit,
  to find all files modified since
- runs a git blame on each to find lines modified since the tag that
  contain '$VERSION'
- prints the filename with a + ($VERSION line modified) or an = ($VERSION
  line not modified)

> I think having the same version number is still much better than having no
> version number at all. That's why I was looking for that solution.

Dist::Zilla's VersionPkg plugin will write the distribution version in every
.pm file of the project.

-- 
 Philippe Bruhat (BooK)

 Life is a play. The secret is to know your lines, respect the other players
 and make a good exit.              (Moral from Groo The Wanderer #12 (Epic))

Reply via email to