Giuseppe Lavagetto has submitted this change and it was merged.

Change subject: deployment: allow fixing the git remote repository
......................................................................


deployment: allow fixing the git remote repository

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

Approvals:
  ArielGlenn: Looks good to me, but someone else must approve
  Giuseppe Lavagetto: Verified; Looks good to me, approved



diff --git a/modules/deployment/files/modules/deploy.py 
b/modules/deployment/files/modules/deploy.py
index b0cfeae..d3c78c3 100644
--- a/modules/deployment/files/modules/deploy.py
+++ b/modules/deployment/files/modules/deploy.py
@@ -770,3 +770,25 @@
         return {'status': status, 'repo': repo, 'dependencies': depstats}
     else:
         return {}
+
+
+def fixurl(git_server):
+    """
+    Allows to recursively fix all the remotes in git repositories on a target.
+    """
+    repo_config = __pillar__.get('repo_config')
+    deployment_target = __grains__.get('deployment_target')
+    for repo in repo_config:
+        if repo not in deployment_target:
+            continue
+        conf = get_config(repo)
+        # If it has not been checked out, there is no reason to fix the url
+        if not __salt__['file.directory_exists'](conf['location']):
+            continue
+
+        cmd = '/usr/bin/git remote set-url origin {0}/.git'.format(
+            conf['url'])
+        retval = __salt__['cmd.retcode'](cmd, cwd=repo_config['location'])
+        if retval != 0:
+            return retval
+    return 0

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ied4bcde607cb1b86f9fed555e2b179daedda858c
Gerrit-PatchSet: 5
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: ArielGlenn <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to