Ottomata has uploaded a new change for review.

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

Change subject: Adding git-fat support for trebuchet deployment
......................................................................

Adding git-fat support for trebuchet deployment

Change-Id: Ib5338575a0240825a87baed9adaa1baafa287754
---
M modules/deployment/files/modules/deploy.py
1 file changed, 52 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/44/112944/1

diff --git a/modules/deployment/files/modules/deploy.py 
b/modules/deployment/files/modules/deploy.py
index d3ab312..b0dd0a6 100644
--- a/modules/deployment/files/modules/deploy.py
+++ b/modules/deployment/files/modules/deploy.py
@@ -109,6 +109,7 @@
         scheme = 'http'
     config['url'] = '{0}://{1}/{2}'.format(scheme, server, repo)
     config.setdefault('checkout_submodules', False)
+    config.setdefault('gitfat_enabled', False)
     config.setdefault('dependencies', {})
     config.setdefault('checkout_module_calls', {})
     config.setdefault('fetch_module_calls', {})
@@ -282,6 +283,50 @@
         if status != 0:
             return status
     return 0
+
+
+def _gitfat_installed():
+    cmd = 'which git-fat'
+    return __salt__['cmd.retcode'](cmd)
+
+def _init_gitfat(location):
+    '''
+    Runs git fat init at this location.
+
+    :param location: The location on the filesystem to run git fat init
+    :type location: str
+    '''
+    # if it isn't then initialize it now
+    cmd = '/usr/bin/git fat init'
+    return __salt__['cmd.retcode'](cmd, location)
+
+
+# TODO: git fat gc?
+def _update_gitfat(location):
+    '''
+    Runs git-fat pull at this location.
+    If git fat has not been initialized for the
+    repository at this location, _init_gitfat
+    will be called first.
+
+    :param location: The location on the filesystem to run git fat pull
+    :type location: str
+    '''
+
+    # Make sure git fat is installed.
+    if _gitfat_installed() != 0:
+        return 40  # TODO: I just made this retval up, what should this be?
+
+    # Make sure git fat is initialized.
+    cmd = '/usr/bin/git config --get filter.fat.smudge'
+    if __salt__['cmd.run'](cmd, location) != 'git-fat filter-smudge':
+        status = _init_gitfat(location)
+        if status != 0:
+            return status
+
+    # Run git fat pull.
+    cmd = '/usr/bin/git fat pull'
+    return __salt__['cmd.retcode'](cmd, location)
 
 
 def _clone(config, location, tag, shadow=False):
@@ -552,6 +597,13 @@
         ret = __salt__['cmd.retcode'](cmd, location)
         if ret != 0:
             return 50
+
+    # Trigger git-fat pull if gitfat_enabled
+    if config['gitfat_enabled']:
+        ret = _update_gitfat(location)
+        if ret != 0:
+            return ret
+
     return 0
 
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5338575a0240825a87baed9adaa1baafa287754
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ottomata <o...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to