18bd5297cSJürgen Schmidt#************************************************************** 29b02d673Smseidel# 38bd5297cSJürgen Schmidt# Licensed to the Apache Software Foundation (ASF) under one 48bd5297cSJürgen Schmidt# or more contributor license agreements. See the NOTICE file 58bd5297cSJürgen Schmidt# distributed with this work for additional information 68bd5297cSJürgen Schmidt# regarding copyright ownership. The ASF licenses this file 78bd5297cSJürgen Schmidt# to you under the Apache License, Version 2.0 (the 88bd5297cSJürgen Schmidt# "License"); you may not use this file except in compliance 98bd5297cSJürgen Schmidt# with the License. You may obtain a copy of the License at 109b02d673Smseidel# 118bd5297cSJürgen Schmidt# http://www.apache.org/licenses/LICENSE-2.0 129b02d673Smseidel# 138bd5297cSJürgen Schmidt# Unless required by applicable law or agreed to in writing, 148bd5297cSJürgen Schmidt# software distributed under the License is distributed on an 158bd5297cSJürgen Schmidt# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 168bd5297cSJürgen Schmidt# KIND, either express or implied. See the License for the 178bd5297cSJürgen Schmidt# specific language governing permissions and limitations 188bd5297cSJürgen Schmidt# under the License. 199b02d673Smseidel# 208bd5297cSJürgen Schmidt#************************************************************** 218bd5297cSJürgen Schmidt 229b02d673Smseidel 239b02d673Smseidel 24*f8d20be8SJim Jagielskipackage RepoRevision; 258bd5297cSJürgen Schmidt 26330ba01cSPeter Kovacs#old SVN code unchanged 27330ba01cSPeter Kovacssub DetectRevisionIdFromSVN ($) 288bd5297cSJürgen Schmidt{ 299b02d673Smseidel my $path = shift; 309b02d673Smseidel 319b02d673Smseidel my $id = undef; 328bd5297cSJürgen Schmidt 339b02d673Smseidel open my $proc, "cd $path && svn info 2>\&1 |"; 349b02d673Smseidel while (<$proc>) 359b02d673Smseidel { 369b02d673Smseidel if (/svn: E155007:/ || /svn: '.' is not a working copy/) 379b02d673Smseidel { 389b02d673Smseidel # Not in an SVN repository. 399b02d673Smseidel $id = DetectRevisionIdFromGit($path); 409b02d673Smseidel last; 419b02d673Smseidel } 429b02d673Smseidel else 439b02d673Smseidel { 449b02d673Smseidel if (/Last Changed Rev:\s+([0-9]+)/) 459b02d673Smseidel { 469b02d673Smseidel $id = $1; 479b02d673Smseidel last; 489b02d673Smseidel } 499b02d673Smseidel } 509b02d673Smseidel } 519b02d673Smseidel close $proc; 528bd5297cSJürgen Schmidt 539b02d673Smseidel return $id; 548bd5297cSJürgen Schmidt} 558bd5297cSJürgen Schmidt 56330ba01cSPeter Kovacs 57330ba01cSPeter Kovacssub DetectRevisionId ($) 58330ba01cSPeter Kovacs{ 599b02d673Smseidel my $path = shift; 60330ba01cSPeter Kovacs 619b02d673Smseidel my $id = undef; 629b02d673Smseidel #test if path points to a git repository. if true return is 0 else positive number. 639b02d673Smseidel my $isNotGit= `[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1`; 649b02d673Smseidel if ($isNotGit) 659b02d673Smseidel { 669b02d673Smseidel $id = DetectRevisionIdFromSVN ($path); 679b02d673Smseidel } 689b02d673Smseidel else 699b02d673Smseidel { 709b02d673Smseidel #returns directly the hash of the current checkout. 719b02d673Smseidel $id = `git log -1 --pretty=format:%h --abbrev=10`; 729b02d673Smseidel } 73330ba01cSPeter Kovacs 749b02d673Smseidel return $id; 75330ba01cSPeter Kovacs} 76330ba01cSPeter Kovacs 778bd5297cSJürgen Schmidt1; 78