From 2f909997313781eae9a71041616bcd406bdfc25a Mon Sep 17 00:00:00 2001 From: "mrowe@apple.com" Date: Thu, 25 Dec 2008 05:26:33 +0000 Subject: [PATCH] Move the guts of determineCurrentSVNRevision to VCSUtils as svnRevisionForDirectory, and make it work for git too. Reviewed by Timothy Hatcher. * Scripts/VCSUtils.pm: * Scripts/webkitdirs.pm: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@39471 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebKitTools/ChangeLog | 10 ++++++++++ WebKitTools/Scripts/VCSUtils.pm | 16 ++++++++++++++++ WebKitTools/Scripts/webkitdirs.pm | 4 +--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog index 75c0e11..5c9bc8d 100644 --- a/WebKitTools/ChangeLog +++ b/WebKitTools/ChangeLog @@ -1,3 +1,13 @@ +2008-12-24 Mark Rowe + + Reviewed by Timothy Hatcher. + + Move the guts of determineCurrentSVNRevision to VCSUtils as svnRevisionForDirectory, + and make it work for git too. + + * Scripts/VCSUtils.pm: + * Scripts/webkitdirs.pm: + 2008-12-22 Nikolas Zimmermann Reviewed by George Staikos. diff --git a/WebKitTools/Scripts/VCSUtils.pm b/WebKitTools/Scripts/VCSUtils.pm index e09d331..5e92821 100644 --- a/WebKitTools/Scripts/VCSUtils.pm +++ b/WebKitTools/Scripts/VCSUtils.pm @@ -104,6 +104,22 @@ sub isSVN() return $isSVN; } +sub svnRevisionForDirectory($) +{ + my ($dir) = @_; + my $revision; + + if (isSVNDirectory($dir)) { + my $svnInfo = `LC_ALL=C svn info $dir | grep Revision:`; + ($revision) = ($svnInfo =~ m/Revision: (\d+).*/g); + } elsif (isGitDirectory($dir)) { + my $gitLog = `cd $dir && LC_ALL=C git log --grep='git-svn-id: ' -n 1 | grep git-svn-id:`; + ($revision) = ($gitLog =~ m/ +git-svn-id: .+@(\d+) /g); + } + die "Unable to determine current SVN revision in $dir" unless (defined $revision); + return $revision; +} + my $gitRoot; sub makeFilePathRelative($) { diff --git a/WebKitTools/Scripts/webkitdirs.pm b/WebKitTools/Scripts/webkitdirs.pm index 95c4a6c..9aafa1a 100644 --- a/WebKitTools/Scripts/webkitdirs.pm +++ b/WebKitTools/Scripts/webkitdirs.pm @@ -212,9 +212,7 @@ sub determineCurrentSVNRevision { return if defined $currentSVNRevision; determineSourceDir(); - my $svnInfo = `LC_ALL=C svn info $sourceDir | grep Revision:`; - ($currentSVNRevision) = ($svnInfo =~ m/Revision: (\d+).*/g); - die "Unable to determine current SVN revision in $sourceDir" unless (defined $currentSVNRevision); + $currentSVNRevision = svnRevisionForDirectory($sourceDir); return $currentSVNRevision; } -- 1.8.3.1