Hi all,
I have adjusted the Function DetectRevisionId in
main/solenv/bin/modules/SvnRevision.pm to return the short hash when
executed in a git repository.
If it is not a git repository, it will fallback to the SVN logic. The
short hash includes a newline. I am not sure if that will make any trouble.
I have attached the patch. Please review. I could not test a complete
build I have some building issues. (I will send some separated mails.)
Also I have not checked in because of the lacking N2N test, and since I
do not know what this newline does.
All the Best
Peter
diff --git a/main/solenv/bin/build.pl b/main/solenv/bin/build.pl
index e997010cfb..f24b5554b2 100755
--- a/main/solenv/bin/build.pl
+++ b/main/solenv/bin/build.pl
@@ -67,9 +67,9 @@
@modes_array = split('\s' , $ENV{BUILD_TYPE});
};
#### script id #####
-
( my $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/;
my $id_str = ' $Revision$ ';
+
my $script_rev = 0;
$id_str =~ /Revision:\s+(\S+)\s+\$/
? ($script_rev = $1) : ($script_rev = "-");
@@ -2602,7 +2602,7 @@ sub read_ssolar_vars {
sub get_solar_vars {
my ($solar_vars, $file) = @_;
my ($var, $value);
- open SOLARTABLE, "<$file" or die "can“t open solarfile $file";
+ open SOLARTABLE, "<$file" or die "can not open solarfile $file";
while(<SOLARTABLE>) {
s/\r\n//o;
next if(!/^\w+\s+(\w+)/o);
diff --git a/main/solenv/bin/getrevision.pl b/main/solenv/bin/getrevision.pl
old mode 100644
new mode 100755
diff --git a/main/solenv/bin/modules/SvnRevision.pm b/main/solenv/bin/modules/SvnRevision.pm
index 5c2c1fc950..85096fdfa9 100644
--- a/main/solenv/bin/modules/SvnRevision.pm
+++ b/main/solenv/bin/modules/SvnRevision.pm
@@ -21,36 +21,7 @@
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 ($)
+sub DetectRevisionIdFromSVN ($)
{
my $path = shift;
@@ -79,4 +50,23 @@ sub DetectRevisionId ($)
return $id;
}
+
+sub DetectRevisionId ($)
+{
+ my $path = shift;
+
+ my $id = undef;
+ my $isNotGit= system("[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1");
+ if ($isNotGit)
+ {
+ $id = DetectRevisionIdFromSVN ($path);
+ }
+ else
+ {
+ $id = system("git log -1 --pretty=format:%h");
+ }
+
+ return $id;
+}
+
1;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]