jenkins-bot has submitted this change and it was merged.

Change subject: multiversion: Add updateSymlink() back in updateBranchPointers
......................................................................


multiversion: Add updateSymlink() back in updateBranchPointers

Follows-up de13291. Oops.

Change-Id: Ibf236d688b071fde7455213a8af3c7b18ff2d631
---
M multiversion/updateBranchPointers
1 file changed, 38 insertions(+), 0 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/multiversion/updateBranchPointers 
b/multiversion/updateBranchPointers
index c11ca2f..cd82234 100755
--- a/multiversion/updateBranchPointers
+++ b/multiversion/updateBranchPointers
@@ -41,6 +41,44 @@
        updateSymlink( MEDIAWIKI_STAGING_DIR . '/php', $phpLinkTarget, $dryRun 
);
 }
 
+/**
+ * @param string $link
+ * @param string $dest
+ * @param bool $dryRun
+ */
+function updateSymlink( $link, $dest, $dryRun ) {
+       // Change pwd to MEDIAWIKI_STAGING_DIR so that relative paths can be 
verified
+       chdir( MEDIAWIKI_STAGING_DIR );
+
+       if ( !file_exists( $dest ) ) {
+               fwrite( STDERR, __FUNCTION__ . ": link target $dest does not 
exist.\n" );
+               exit( 1 );
+       }
+
+       if ( file_exists( $link ) ) {
+               if ( realpath( $link ) === realpath( $dest ) ) {
+                       echo "$link is already up-to-date.\n";
+                       return;
+               }
+
+               if ( !is_link( $link ) ) {
+                       fwrite( STDERR, __FUNCTION__ . ": $link exists and is 
not a symbolic link.\n" );
+                       exit( 1 );
+               }
+
+               if ( !$dryRun && !unlink( $link ) ) {
+                       fwrite( STDERR, __FUNCTION__ . ": failed to unlink 
$link\n" );
+                       exit( 1 );
+               }
+       }
+
+       if ( !$dryRun && !symlink( $dest, $link ) ) {
+               fwrite( STDERR, __FUNCTION__ . ": failed to create $link\n" );
+               exit( 1 );
+       }
+       echo "$link => $dest\n";
+}
+
 
 if ( isMain() ) {
        $dryRun = in_array( '--dry-run', $argv, true );

-- 
To view, visit https://gerrit.wikimedia.org/r/276746
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibf236d688b071fde7455213a8af3c7b18ff2d631
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to