
On Saturday 2014-01-11 00:40, Adam Spiers wrote:
Please can you explain exactly how you would programmatically obtain the "tag-offset"
It's described in text form in the wiki article. #!/usr/bin/perl use IPC::Open3; use strict; sub grab { local(*CIN, *COUT, *CERR); my $pid = open3(\*CIN, \*COUT, \*CERR, @_); chomp(my $line = <COUT>); close(CIN); close(COUT); close(CERR); waitpid($pid, 0); return ($line, $? >> 8); # need something better than "$?"? } sub result { print "Version: $_[0]\n"; exit(0); } my $commit = shift(@ARGV) || "HEAD"; my $pattern = shift(@ARGV) || "*"; my @args = ("git", "describe", "--match=$pattern", "--abbrev=0", $commit); my($base, $err) = &grab(@args); if ($err != 0) { chomp(my $len = `git rev-list "$commit" | wc -l`); &result("0~git$len"); } splice(@args, 3, 1); # remove --abbrev=0 my($offset) = &grab(@args); &result($base) if ($base eq $offset); &result("$base~git$offset") if ($offset =~ s{^\Q$base\E-(\d+)-g\w+$}{$1}); print STDERR "This should not happen.\n"; exit(1);
The version ought to be monotonically increasing somehow. The timestamp does that, sure, but so does the tag-offset (for a given branch that is being continuously packaged)
and explain why it is reliably monotonically increasing?
If you stay on a given branch, if you make a commit, you add +1 to the distance. If you make a merge commit, you add some +n (n>0) to the reported distance. It _can't_ go backwards.
For example, if a non-release tag is introduced into the repository, how would you ensure that the tag-offset doesn't suddenly drop back to zero?
git describe --match= One would at least hope you name your release tags reasonably unique that they are programmatically distinguishable from nonrel tags (that would also be worthwhile from a human perspective).
And then there's still the case where there are no tags, and I don't agree with the point of view that every repository should have tags.
And the wiki page (and the perl above) has a solution for that as well, which would tell me you did not visit the wiki page again ever since last September's discussion. -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org