Hello Thcipriani,

I'd like you to do a code review.  Please visit

    https://gerrit.wikimedia.org/r/392723

to review the following change.


Change subject: updatewikiversions: Only attempt symlink change if needed
......................................................................

updatewikiversions: Only attempt symlink change if needed

Right now the plugin lies and always tells you we've updated the
symlink. If we don't need to, don't bother.

While we're here: fix a variable comparison and add some documentation

Change-Id: I444a3c12b2c87d35c6402447f9aedd51a2a2d4d8
---
M scap/plugins/updatewikiversions.py
1 file changed, 8 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/23/392723/1

diff --git a/scap/plugins/updatewikiversions.py 
b/scap/plugins/updatewikiversions.py
index 6d51c8d..1ffb516 100644
--- a/scap/plugins/updatewikiversions.py
+++ b/scap/plugins/updatewikiversions.py
@@ -18,6 +18,7 @@
                   help='The dblist file to use as input for migrating.')
     @cli.argument('branch', help='The name of the branch to migrate to.')
     def main(self, *extra_args):
+        """Update the json file, maybe update the branch symlink"""
         self.update_wikiversions_json()
         self.update_branch_pointer()
 
@@ -46,7 +47,7 @@
             with open(json_path) as json_in:
                 version_rows = json.load(json_in)
         else:
-            if db_list_name is not 'all':
+            if db_list_name != 'all':
                 raise RuntimeError(
                     'No %s file and not invoked with "all."' % json_path +
                     'Cowardly refusing to act.'
@@ -80,9 +81,9 @@
         """
         cur_version = self.active_wikiversions().popitem()[0]
 
-        utils.move_symlink(
-            os.path.join(self.config['stage_dir'],
-                         'php-%s' % cur_version),
-            os.path.join(self.config['stage_dir'], 'php')
-        )
-        self.get_logger().info('Symlink updated')
+        real_path = os.path.join(
+            self.config['stage_dir'], 'php-%s' % cur_version)
+        symlink = os.path.join(self.config['stage_dir'], 'php')
+        if os.path.realpath(symlink) != real_path:
+            utils.move_symlink(real_path, symlink)
+            self.get_logger().info('Symlink updated')

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I444a3c12b2c87d35c6402447f9aedd51a2a2d4d8
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>
Gerrit-Reviewer: Thcipriani <[email protected]>

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

Reply via email to