BryanDavis has uploaded a new change for review.

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

Change subject: Support Github URLs
......................................................................

Support Github URLs

Github URLs for MediaWiki projects have a predictable variation from the
Gerrit originals. Add support in git::clone for transforming the
repository name from Gerrit format to Github format when the default
$git::urlformat references Github.

Using this change it is possible to clone MediaWiki and extensions from
Github by setting:

  git::urlformat: 'https://github.com/wikimedia/%s.git'

in puppet/hieradata/local.yaml prior to the first `vagrant up` for a new
MediaWiki-Vagrant deployment. Changing the hiera value for
git::urlformat will not effect any existing git clones.

Bug: 56046
Change-Id: Ie90cef95552e9a5444ee7dcef953371848840852
---
M puppet/hieradata/common.yaml
M puppet/modules/git/manifests/clone.pp
M puppet/modules/git/manifests/init.pp
3 files changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant 
refs/changes/95/157695/1

diff --git a/puppet/hieradata/common.yaml b/puppet/hieradata/common.yaml
index 84251b9..201955d 100644
--- a/puppet/hieradata/common.yaml
+++ b/puppet/hieradata/common.yaml
@@ -14,6 +14,8 @@
 crm::db_user: root
 crm::db_pass: "%{hiera('mysql::root_password')}"
 
+git::urlformat: 'https://gerrit.wikimedia.org/r/%s'
+
 hhvm::logroot: /vagrant/logs
 
 mediawiki::wiki_name: devwiki
diff --git a/puppet/modules/git/manifests/clone.pp 
b/puppet/modules/git/manifests/clone.pp
index 95c7a97..68685f9 100644
--- a/puppet/modules/git/manifests/clone.pp
+++ b/puppet/modules/git/manifests/clone.pp
@@ -60,8 +60,13 @@
         fail('ensure parameter must be present or latest.')
     }
 
+    $repo_path = $::git::urlformat ? {
+        /github\.com/ => regsubst($title, '/', '-', 'G'),
+        default       => $title,
+    }
+
     $repository = $remote ? {
-        undef   => sprintf($git::urlformat, $title),
+        undef   => sprintf($::git::urlformat, $repo_path),
         default => $remote,
     }
 
diff --git a/puppet/modules/git/manifests/init.pp 
b/puppet/modules/git/manifests/init.pp
index 1dc38eb..71c875d 100644
--- a/puppet/modules/git/manifests/init.pp
+++ b/puppet/modules/git/manifests/init.pp
@@ -9,7 +9,7 @@
 #   the remote repository URL is constructed by interpolating the title
 #   of the resource into the format string below. This provides a
 #   convenient syntactic sugar for cloning Gerrit repositories.
-#   Default: 'https://gerrit.wikimedia.org/r/p/%s.git'.
+#   Example: 'https://gerrit.wikimedia.org/r/p/%s.git'.
 #
 # [*default_depth*]
 #   Default depth for git clones. If specified, creates a shallow clone with
@@ -23,7 +23,7 @@
 #  }
 #
 class git(
-    $urlformat = 'https://gerrit.wikimedia.org/r/p/%s.git',
+    $urlformat,
     $default_depth = undef,
 ) {
     package { 'git':

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie90cef95552e9a5444ee7dcef953371848840852
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <bda...@wikimedia.org>

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

Reply via email to