Changeset 206283 in webkit
- Timestamp:
- Sep 22, 2016 6:14:59 PM (8 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r206282 r206283 1 2016-09-22 Matthew Hanson <matthew_hanson@apple.com> 2 3 Add an API for getting the branch identifier from a Git or SVN checkout. 4 https://bugs.webkit.org/show_bug.cgi?id=151570 5 rdar://problem/17959831 6 7 Reviewed by David Kilzer. 8 9 This patch adds a function called svnIdentifierForPath. This function returns either "trunk", 10 the name of the tag, or the name of the branch, as appropriate. This function is necessary for 11 a VCSUtils client that is not checked in to the WebKit project. 12 13 This patch also breaks up pathRelativeToSVNRepositoryRootForPath into four functions: 14 - pathRelativeToSVNRepositoryRootForPath 15 - svnInfoForPath 16 - svnURLForPath 17 - svnRepositoryRootForPath 18 19 This allows us to reuse logic from pathRelativeToSVNRepositoryRootForPath in svnIdentifierForPath and 20 allows clients of VCSUtils to extract what arbitrary information from the `svn info` command regardless 21 of SCM. 22 23 * Scripts/VCSUtils.pm: 24 (svnInfoForPath): 25 Copied logic that previously lived in pathRelativeToSVNRepositoryRootForPath. 26 Make code safe to use for a path, and not just for the CWD. 27 28 (svnURLForPath): 29 Calls svnInfoForPath and extracts the URL. 30 31 (svnRepositoryRootForPath): 32 Calls svnInfoForPath and extracts the Repository Root. 33 34 (svnIdentifierForPath): 35 Calls pathRelativeToSVNRepositoryRootForPath and extracts the repository identifier. 36 37 (pathRelativeToSVNRepositoryRootForPath): 38 Now uses svnURLForPath and svnRepositoryRootForPath instead of being responsible for 39 determining both values. 40 1 41 2016-09-22 Megan Gardner <megan_gardner@apple.com> 2 42 -
trunk/Tools/Scripts/VCSUtils.pm
r204549 r206283 88 88 &scmToggleExecutableBit 89 89 &setChangeLogDateAndReviewer 90 &svnIdentifierForPath 91 &svnInfoForPath 92 &svnRepositoryRootForPath 90 93 &svnRevisionForDirectory 91 94 &svnStatus 95 &svnURLForPath 92 96 &toWindowsLineEndings 93 97 &gitCommitForSVNRevision … … 445 449 } 446 450 447 sub pathRelativeToSVNRepositoryRootForPath($)451 sub svnInfoForPath($) 448 452 { 449 453 my ($file) = @_; … … 451 455 452 456 my $svnInfo; 453 if (isSVN ()) {457 if (isSVNDirectory($file)) { 454 458 my $escapedRelativePath = escapeSubversionPath($relativePath); 455 459 my $command = "svn info $escapedRelativePath"; 456 460 $command = "LC_ALL=C $command" if !isWindows(); 457 461 $svnInfo = `$command`; 458 } elsif (isGit ()) {459 my $command = "git svn info $relativePath";462 } elsif (isGitDirectory($file)) { 463 my $command = "git svn info"; 460 464 $command = "LC_ALL=C $command" if !isWindows(); 461 $svnInfo = `$command`; 462 } 465 $svnInfo = `cd $relativePath && $command`; 466 } 467 468 return $svnInfo; 469 } 470 471 sub svnURLForPath($) 472 { 473 my ($file) = @_; 474 my $svnInfo = svnInfoForPath($file); 463 475 464 476 $svnInfo =~ /.*^URL: (.*?)$/m; 465 my $svnURL = $1; 477 return $1; 478 } 479 480 sub svnRepositoryRootForPath($) 481 { 482 my ($file) = @_; 483 my $svnInfo = svnInfoForPath($file); 466 484 467 485 $svnInfo =~ /.*^Repository Root: (.*?)$/m; 468 my $repositoryRoot = $1; 469 470 $svnURL =~ s/$repositoryRoot\///; 486 return $1; 487 } 488 489 sub pathRelativeToSVNRepositoryRootForPath($) 490 { 491 my ($file) = @_; 492 493 my $svnURL = svnURLForPath($file); 494 my $svnRepositoryRoot = svnRepositoryRootForPath($file); 495 496 $svnURL =~ s/$svnRepositoryRoot\///; 471 497 return $svnURL; 498 } 499 500 sub svnIdentifierForPath($) 501 { 502 my ($file) = @_; 503 my $path = pathRelativeToSVNRepositoryRootForPath($file); 504 505 $path =~ /^(trunk)|tags\/([\w\.\-]*)|branches\/([\w\.\-]*).*$/m; 506 return $1 || $2 || $3; 472 507 } 473 508
Note: See TracChangeset
for help on using the changeset viewer.