Ticket #1845 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

Need comparable revision information in parrot_config output

Reported by: moritz Owned by: dukeleto
Priority: blocker Milestone: 2.10
Component: configure Version: 2.10.0
Severity: medium Keywords:
Cc: gerd Language:
Patch status: Platform:

Description

Currently parrot-on-git doesn't provide revision information besides the SHA1 hash, which is not suitable for comparing it to other revisions if no parrot git repo is available.

We should have the following config keys available * revision - last svn revision * sha1 - git SHA1 * git_revision - output from git describe --tags

Before we decided that we want all three, I wrote a small patch to change the 'revision' key to git-describe output.

From 63833e6a9b47bba9ed7d678544cb6c71135f0ae0 Mon Sep 17 00:00:00 2001
From: Moritz Lenz <moritz@faui2k3.org>
Date: Tue, 9 Nov 2010 19:14:12 +0100
Subject: [PATCH] switch revision config to "git describe" output

The rationale is that it allows HLL devs to compare parrot revisions without
having a git repo of parrot available.
---
 config/auto/revision.pm |    2 +-
 lib/Parrot/Revision.pm  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/config/auto/revision.pm b/config/auto/revision.pm
index efbc014..870c3df 100644
--- a/config/auto/revision.pm
+++ b/config/auto/revision.pm
@@ -32,7 +32,7 @@ sub runstep {
 
     my $revision = $Parrot::Revision::current;
 
-    if ( defined($revision) and $revision !~ /^[a-z0-9]+$/i ) {
+    if ( defined($revision) and $revision !~ /^[-\w]+-\d+-g[a-f0-9]+$/i ) {
         die "Invalid Parrot revision (SHA1): $!";
     }
 
diff --git a/lib/Parrot/Revision.pm b/lib/Parrot/Revision.pm
index f7efa8f..560797c 100644
--- a/lib/Parrot/Revision.pm
+++ b/lib/Parrot/Revision.pm
@@ -84,7 +84,7 @@ sub _analyze_sandbox {
     # Avoid locale troubles
     local $ENV{LANG}   = 'C';
     local $ENV{LC_ALL} = 'C';
-    chomp($revision = qx/git rev-parse HEAD/);
+    chomp($revision = qx/git describe --tags/);
     return $revision;
 }
 
-- 
1.7.2.3

Change History

Changed 4 years ago by nwellnhof

What about using the timestamp of the most recent commit, i.e. the output of

git log -1 --pretty=format:%ct

Changed 4 years ago by moritz

Timestamps are pretty fragile. Take a very old branch, add just one commit, and the comparison function will identify it as new enough. Which is why I prefer the git-describe output.

Changed 4 years ago by nwellnhof

We can always check the Parrot version, so there should never be very old branches. I also don't see how using git-describe would avoid any problems that can happen with SVN revisions or timestamps. AFAICS the only useful info you get from git-describe is the number of commits that you're ahead of a tagged commit which is probably the last official Parrot release. If you're on a random branch this number could be anything. I think that's even more fragile than timestamps.

Changed 4 years ago by gerd

Suggestion:

git log | grep "^commit" | wc -l

Changed 4 years ago by moritz

  • status changed from new to closed
  • resolution set to fixed

Counting commits makes it easier to compare, but harder to go from the number to something that git checkout understands.

So I'm sticking with git describe output, and since dukeleto++ implemented it, I'm closing this ticket now.

Changed 4 years ago by gerd

  • cc gerd added

Uups, the ticket is already closed.

Anyway the code for counting commits in Perl 5 would be:

#!/usr/bin/perl

my $revision=0;

open (GIT_LOG, 'git log |');
while (<GIT_LOG>) {
    $revision++ if /^commit/;
}
print $revision;

close GIT_LOG;
Note: See TracTickets for help on using tickets.