This is an automated email from the ASF dual-hosted git repository.

petko pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 330ba01  SvnRevision.pm returns now short git hash. git-svn-id has 
been removed.
     new ed36707  Merge branch 'trunk' of 
https://gitbox.apache.org/repos/asf/openoffice into trunk
330ba01 is described below

commit 330ba01c72ab1519ff7fe9dff14e9b603201da0b
Author: Peter Kovacs <pe...@apache.org>
AuthorDate: Tue Aug 13 20:39:48 2019 +0200

    SvnRevision.pm returns now short git hash. git-svn-id has been removed.
---
 main/solenv/bin/modules/SvnRevision.pm | 53 +++++++++++++++-------------------
 1 file changed, 23 insertions(+), 30 deletions(-)

diff --git a/main/solenv/bin/modules/SvnRevision.pm 
b/main/solenv/bin/modules/SvnRevision.pm
index 5c2c1fc..eab9538 100644
--- a/main/solenv/bin/modules/SvnRevision.pm
+++ b/main/solenv/bin/modules/SvnRevision.pm
@@ -21,36 +21,8 @@
 
 package SvnRevision;
 
-
-sub DetectRevisionIdFromGit ($)
-{
-    my $path = shift;
-    
-    my $id = undef;
-
-    open my $proc, "cd $path && git show HEAD 2>\&1|";
-    while (<$proc>)
-    {
-        if (/^fatal: Not a git repository/)
-        {
-            # Not in a GIT repository.
-            last;
-        }
-        elsif (/^\s*git-svn-id:.*?@([0-9]+)\s+/)
-        {
-            $id = $1;
-            last;
-        }
-    }
-    close $proc;
-
-    return $id;
-}
-
-
-
-
-sub DetectRevisionId ($)
+#old SVN code unchanged
+sub DetectRevisionIdFromSVN ($)
 {
     my $path = shift;
 
@@ -79,4 +51,25 @@ sub DetectRevisionId ($)
     return $id;
 }
 
+
+sub DetectRevisionId ($)
+{
+    my $path = shift;
+
+    my $id = undef;
+    #test if path points to a git repository. if true return is 0 else 
positive number.
+    my $isNotGit= `[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1`;
+    if ($isNotGit)
+    {
+       $id = DetectRevisionIdFromSVN ($path);
+    }
+    else
+    {
+       #returns directly the hash of the current checkout.
+       $id = `git log -1 --pretty=format:%h`;
+    }
+
+    return $id;
+}
+
 1;

Reply via email to