Siebrand has uploaded a new change for review.

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

Change subject: Add repo type 'gitwithusername'
......................................................................

Add repo type 'gitwithusername'

- This enables support for FreeCol, FUDforum and NOCC that use read-write URLs 
like
  ssh://siebr...@git.code.sf.net/p/freecol/git. USERNAME will be replace by the
  username of the user running the script.
- Add a username conversion table, analogous to the THISUSER feature in 
REPOCONF.commit

Change-Id: I12701001fceaf0a26ece694a3eb27e6e9b05fd2c
---
M repong/repong.php
1 file changed, 15 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/translatewiki 
refs/changes/92/290192/1

diff --git a/repong/repong.php b/repong/repong.php
index 91daff6..24cce40 100644
--- a/repong/repong.php
+++ b/repong/repong.php
@@ -8,6 +8,9 @@
        protected $bindir;
        protected $meta;
        protected $config;
+       protected $usernameConversion = [
+               'nike' => 'nikerabbit',
+       ];
 
        public function __construct( array $meta, array $config ) {
                $this->bindir = realpath( __DIR__ . '/../bin' );
@@ -27,6 +30,17 @@
                        if ( $repo['type'] === 'git' ) {
                                $branch = isset( $repo['branch'] ) ? 
$repo['branch'] : 'master';
                                $command = $this->bindir . "/clupdate-git-repo 
'{$repo['url']}' '$base/$name' '$branch'";
+                       } elseif ( $repo['type'] === 'gitwithusername' ) {
+                               $branch = isset( $repo['branch'] ) ? 
$repo['branch'] : 'master';
+
+                               $userName = get_current_user();
+                               if ( isset( 
$this->usernameConversion[$userName] ) ) {
+                                       $userName = 
$this->usernameConversion[$userName];
+                               }
+
+                               $repoUrl = $repo['url'];
+                               $repoUrl = str_replace( 'USERNAME', $userName, 
$repoUrl );
+                               $command = $this->bindir . "/clupdate-git-repo 
'{$repoUrl}' '$base/$name' '$branch'";
                        } elseif ( $repo['type'] === 'wmgerrit' ) {
                                $branch = isset( $repo['branch'] ) ? 
$repo['branch'] : 'master';
                                $command = $this->bindir . 
"/clupdate-gerrit-repo '{$repo['url']}' '$base/$name' '$branch'";
@@ -95,7 +109,7 @@
 
                                $gerritCommitted = true;
                        } else {
-                               throw new RuntimeException( "Unknown repo type" 
);
+                               throw new RuntimeException( 'Unknown repo type' 
);
                        }
                        echo "$command\n";
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I12701001fceaf0a26ece694a3eb27e6e9b05fd2c
Gerrit-PatchSet: 1
Gerrit-Project: translatewiki
Gerrit-Branch: master
Gerrit-Owner: Siebrand <siebr...@kitano.nl>

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

Reply via email to