You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ji...@apache.org on 2019/08/15 12:12:22 UTC
[openoffice] branch AOO417 updated: SvnRevision.pm returns now
short git hash. git-svn-id has been removed.
This is an automated email from the ASF dual-hosted git repository.
jim pushed a commit to branch AOO417
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO417 by this push:
new a530506 SvnRevision.pm returns now short git hash. git-svn-id has been removed.
a530506 is described below
commit a530506ffaaff48afd7cc213c213f4733f3a1f48
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;