Last modified: 2013-07-17 14:30:44 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T49274, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 47274 - Gerrit: Custom repo name mapping for GitHub mirror
Gerrit: Custom repo name mapping for GitHub mirror
Status: RESOLVED FIXED
Product: Wikimedia
Classification: Unclassified
Git/Gerrit (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-04-16 02:22 UTC by Diederik van Liere
Modified: 2013-07-17 14:30 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Diederik van Liere 2013-04-16 02:22:43 UTC
Currently, Gerrit repositories get automatically prefixed with their parent project such that the 'puppet' repo is called 'operations-puppet'. This is a request to allow for custom naming of the Github repo.
Comment 1 Andrew Otto 2013-04-16 16:59:39 UTC
Currently the gerrit replication plugin only supports minimal slash '/' replacement in gerrit repository names.  We'd like to add support for arbitrary mapping from a gerrit repository name to any name in a replication.config file.
Comment 2 christian 2013-04-16 19:13:45 UTC
(In reply to comment #0)
> Currently, Gerrit repositories get automatically prefixed with their parent
> project such that the 'puppet' repo is called 'operations-puppet'.

In gerrit, project names are strings. Slash is not a special
character. For example “operations/dumps” is not the parent of
“operations/dumps/archiving”. For gerrit, those two projects are
unrelated.

> operations-puppet

Some git servers do not like special characters (like '/') in their
repo names. So for example if you try to create a repository on github
with name

  operations/puppet

github presents a warning

  Will be created as operations-puppet

. Hence, indeed “operations-puppet” is the correct github name for
“operations/puppet”.
Comment 3 christian 2013-04-16 19:18:03 UTC
(In reply to comment #1)
> Currently the gerrit replication plugin only supports minimal slash '/'
> replacement in gerrit repository names.

That's only partly true. You can push to whatever Url you like, so you
can push to whatever name you choose. So any renaming is possible
already now.

However, automatic substituting of ${name} is currently only
implemented for

* '/' -> '-', and
* '/' -> '_'.

> We'd like to add support for
> arbitrary
> mapping from a gerrit repository name to any name in a replication.config
> file.

That sounds like a request for obfuscation to me :-)

Or is there something wrong with the way we name our repos in gerrit?

If you do not want to do automatic mangling of ${name} you can go
straight for the Url to push to. If you prefer automatic mangling, the
code at
src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java:getURIs:360
in the replication plugin should get you started.

P.S.: Bear in mind that the other day, someone asked how to arrive at a
repo's gerrit name, if all we know is the github's repo name. So I'd be
all for keeping the translation between names as simple as possible
... and if that's possible: reasonaly close to being two-way.
Comment 4 Andrew Otto 2013-04-16 19:35:08 UTC
> Or is there something wrong with the way we name our repos in gerrit?
I think yes, but this is a big discussion I haven't had the guts to start yet.

Motivation:

I am maintaining puppet-cdh4 on github.  I have active contributors I don't want to lose.
I need to move the main hosting of this project over to gerrit. Operations wants me to name this operations/puppet/cdh4, which when replicated to github will be operations-puppet-cdh4.  I think it is more correct to name this gerrit repo puppet/cdh4, since the puppet module itself is 100% non WMF operations specific.  But, unless/until that discussion is settled, I have to keep name this under the operations/ prefix.

Arbitrary name mapping would allow us to side step this problem, and to make gerrit projects that we want to be prominent open source contributions to be more visible to the world on Github.
Comment 5 Andrew Otto 2013-04-16 19:35:37 UTC
BTW, I have had long discussions with Chad and Mark and Faidon about this.  I even discussed implementation with Chad a bit about it.
Comment 6 Chad H. 2013-04-16 19:48:29 UTC
(In reply to comment #5)
> BTW, I have had long discussions with Chad and Mark and Faidon about this.  I
> even discussed implementation with Chad a bit about it.

Yes, and I wasn't opposed to it at the time...but then this happened:

(In reply to comment #3)
> P.S.: Bear in mind that the other day, someone asked how to arrive at a
> repo's gerrit name, if all we know is the github's repo name. So I'd be
> all for keeping the translation between names as simple as possible
> ... and if that's possible: reasonaly close to being two-way.

And the problems of breaking the 1:1 mapping became clear. Again, it's not a deal breaker, but it does present problems.
Comment 7 Andrew Otto 2013-04-16 19:51:43 UTC
> If you do not want to do automatic mangling of ${name} you can go
straight for the Url to push to.

Hm, wait, we can do this manually?  That's fine for my purposes.  I'm not sure how though.  As far as I can tell, the replication.config handles replication of all repositories to each defined remote and url.  How would a replication.config section that only replicates a particular repository with a manual url (no ${name}) expansion look?
Comment 8 Diederik van Liere 2013-04-17 00:09:13 UTC
But how important is it really to be able to automatically infer the Gerrit repo name from the github repo name? A simple reference in the README.md to the Gerrit repo name can do as well.
Comment 9 jeremyb 2013-04-17 00:32:34 UTC
In addition to the README you can set the URL for the repo to be the URL for the same repo at gerrit unless there's some better place to link to. But yeah, README should be good enough in the few cases where it's not a 1:1 mapping.
Comment 10 christian 2013-04-17 11:02:19 UTC
(In reply to comment #7)
> > If you do not want to do automatic mangling of ${name} you can go
> straight for the Url to push to.
> 
> Hm, wait, we can do this manually?  That's fine for my purposes.

Yes, of course you can :-) ... But then I realized that I added this
functionality only locally, when testing replication some time back
:-(

I now added documentation and pushed it to upstream:
https://gerrit-review.googlesource.com/#/c/44710/

It does not meet this bug's request to have custom renaming, but it
would allow to replicate
  operations/puppet/cdh4 (gerrit) -> puppet-cdh4 (github)
in /addition/ to the standard
  operations/puppet/cdh4 (gerrit) -> operations-puppet-cdh4 (github)
. To get this, you'd just have to add another remote section to
gerrit's repository.config. Something like:

[remote "github-extra-cd4"]
	url = [github-push-url]/puppet-cdh4
	project = operations/puppet/cdh4

That said, I am still not yet convinced that departing from our 1:1
mapping is a good idea... fortunately, I need not decide that :-)
Comment 11 Chad H. 2013-04-17 11:36:47 UTC
I wonder if we could combine the approach I did awhile back in https://gerrit-review.googlesource.com/#/c/37711/ with that.
Comment 12 Andrew Otto 2013-04-17 12:36:30 UTC
Awesome!  This is all I really need to feel all warm and squishy.

Is this live in our gerrit?  Or do we need to wait until its accepted and we upgrade?
Comment 13 Chad H. 2013-04-17 12:41:31 UTC
Would like them merged so we don't fork, but since they're parts of the replication plugin (and not core) upgrading is easy.
Comment 14 Andrew Otto 2013-04-19 15:13:09 UTC
Hm, ok.  Any idea of how long it might take to get them merged and upgraded?
Comment 15 Andrew Otto 2013-05-14 18:00:26 UTC
Bump!  How goes it? :)
Comment 16 Krinkle 2013-05-14 18:03:33 UTC
Fixing topic to mention GitHub instead of Git.
Comment 17 Andrew Otto 2013-06-21 17:54:39 UTC
Krinkle, I think the mirror git URL is arbitrary, we just happen to use mailny GitHub as a mirror.

Aaaaand, any updates on this? :)
Comment 18 Gerrit Notification Bot 2013-06-29 21:33:41 UTC
Change 71248 had a related patch set (by QChris) published:
Replicate operations/puppet/cdh4 to puppet-cdh4 on github

https://gerrit.wikimedia.org/r/71248
Comment 19 christian 2013-06-29 21:37:46 UTC
(In reply to comment #17)
> Aaaaand, any updates on this? :)

Of course, there are updates: Gerrit has been upgraded, so we should
finally be able to get custom replication working.

Above change should replicate operations/puppet/cdh4 additionally to
puppet-cdh4 on github.

Are there other repos as well that have a following under a different name?
Comment 20 Gerrit Notification Bot 2013-07-02 19:46:28 UTC
Change 71248 merged by Ottomata:
Replicate operations/puppet/cdh4 to puppet-cdh4 on github

https://gerrit.wikimedia.org/r/71248
Comment 21 Andrew Otto 2013-07-02 19:48:14 UTC
There are more repos!  Let's see if this works, then I will work with you to get the rest syncing.
Comment 22 christian 2013-07-17 14:30:44 UTC
With the latest update of gerrit some weeks back, it's possible to
replicate repos to other additional names.

In the meantime, this happened at least for
* operations/puppet/cdh4
* operations/puppet/jmxtrans
* analytics/kafka
and it's working fine.

If it's custom replication is required for further projects, it can
be realized in the same way.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links