Is there a supported way to rename a project in gerrit

3,244 views
Skip to first unread message

thomasmu...@yahoo.com

unread,
Mar 6, 2018, 3:01:07 PM3/6/18
to Repo and Gerrit Discussion
Hi, is there a supported way to rename projects in gerrit?

I see there is a repo for this but no code in it https://gerrit.googlesource.com/plugins/rename-project/

Hugo Arès

unread,
Mar 6, 2018, 3:52:26 PM3/6/18
to Repo and Gerrit Discussion
Currently, no.

As a workaround, you can always use the importer plugin and copy the project then delete
it with delete-project plugin. We are currently doing that but this is far from ideal, it takes a
very long time to "rename" projects when they have a lot of changes. Users keep working
on the source repo while copy is happening, you need to resume copy...and so on.

For this reason, we started to implement a rename-project plugin. So far, we have a
working proof of concept that renames projects which do not have children. The plugin is
based on 2.14.

I was planing to open source it eventually when we have a bit more done but maybe I
can open source it sooner if there is interest.

I checked the empty project on gerrit-review and it's owned by plugins-rename-project
group. Is there someone (Edwin?) who belongs to that group who could add me as a
member?

Hugo

David Ostrovsky

unread,
Mar 6, 2018, 4:01:24 PM3/6/18
to Repo and Gerrit Discussion

On Tuesday, March 6, 2018 at 9:52:26 PM UTC+1, Hugo Arès wrote:
Currently, no.

As a workaround, you can always use the importer plugin and copy the project then delete
it with delete-project plugin. We are currently doing that but this is far from ideal, it takes a
very long time to "rename" projects when they have a lot of changes. Users keep working
on the source repo while copy is happening, you need to resume copy...and so on.

For this reason, we started to implement a rename-project plugin. So far, we have a
working proof of concept that renames projects which do not have children. The plugin is
based on 2.14.

I was planing to open source it eventually when we have a bit more done but maybe I
can open source it sooner if there is interest.


+1. I always support open source stuff ASAP.
 
I checked the empty project on gerrit-review and it's owned by plugins-rename-project
group. Is there someone (Edwin?) who belongs to that group who could add me as a
member?

Hm.., I also don't have the right to see/modify plugins-rename-project group.

Hugo Arès

unread,
Mar 6, 2018, 4:10:34 PM3/6/18
to Repo and Gerrit Discussion

Edwin created that project and set the access rights, he is probably a member of that group

Luca Milanesio

unread,
Mar 6, 2018, 6:19:51 PM3/6/18
to Hugo Arès, Luca Milanesio, Repo and Gerrit Discussion
We had implemented in the past a "rename project" plugin and presented to Shawn ... but his objection was: how do you manage the situation where the same name is then reused with a new project?

The problem is the following:

T-0: Create project 'foo'

Change #1 created and merged against foo
URLs created and archived all around the place, including Jiras and CIs, pointing to foo

T-1: Rename project 'foo' to 'bar'

Change #1 needs to be updated in ReviewDb as all the 'foo' needs to become 'bar'
URLs in Gerrit pointing to 'foo' need to be redirected to 'bar'. Existing URLs will still work and will get a 302.

T-2: Create a new project 'foo'

Now ... what shall we do with 'foo'? Is that the "OLD" name to be redirected? or is the "NEW" project called 'foo'?

--- * ---

At the end of the day Shawn told me: can you explain to me the difference between rename project and create a new project with a new name and all the content of the old project and make the old project read-only and invisible?

Luca.

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luca Milanesio

unread,
Mar 6, 2018, 6:35:49 PM3/6/18
to Hugo Arès, Luca Milanesio, Repo and Gerrit Discussion
That is the thread that generated the empty 'rename-project' plugin:

It was originally created for Chad ... and never implemented :-(

Luca.

Luca Milanesio

unread,
Mar 6, 2018, 6:41:49 PM3/6/18
to Hugo Arès, Luca Milanesio, Repo and Gerrit Discussion
*BUT* ... if the 'rename-project' plugin actually does what Shawn was saying:

1. Create a new project
2. Move the content to the new project, including reviews
3. Define redirection from old URL to the new URL
4. Forbid the creation and reuse of the old name 

then I do not see any potential problem with it and it would be very useful indeed :-)

+1 to have a plugin for that.

Luca.

On 6 Mar 2018, at 23:19, Luca Milanesio <luca.mi...@gmail.com> wrote:

chor...@wikimedia.org

unread,
Mar 6, 2018, 9:48:33 PM3/6/18
to Repo and Gerrit Discussion
Yeah. Christian and I never really got past a lot of the nasty implementation details (hence his string of abandoned work in core as well). Generally these days I agree with your earlier statement that it's just simpler to copy--well, create a new repo and import history--to the new name. In which case you can either delete the old one or have it point to the new one (empty it all but a README or something pointing to new location). Barring some "redirect" behavior a rename would be generally harmful. /Especially/ in newer Gerrit versions where the repo name is part of the change URL.

At Wikimedia, we tend to just do as I suggest above: empty the repo except a README file (actually, we go with OBSOLETE) and then mark it as read-only.

-Chad
Luca.

Luca.

Edwin Kempin

unread,
Mar 7, 2018, 2:14:57 AM3/7/18
to Hugo Arès, Repo and Gerrit Discussion
On Tue, Mar 6, 2018 at 9:52 PM, Hugo Arès <hugo...@ericsson.com> wrote:
Currently, no.

As a workaround, you can always use the importer plugin and copy the project then delete
it with delete-project plugin. We are currently doing that but this is far from ideal, it takes a
very long time to "rename" projects when they have a lot of changes. Users keep working
on the source repo while copy is happening, you need to resume copy...and so on.

For this reason, we started to implement a rename-project plugin. So far, we have a
working proof of concept that renames projects which do not have children. The plugin is
based on 2.14.

I was planing to open source it eventually when we have a bit more done but maybe I
can open source it sooner if there is interest.

I checked the empty project on gerrit-review and it's owned by plugins-rename-project
group. Is there someone (Edwin?) who belongs to that group who could add me as a
member?
I've added you to this group.
 


Hugo


On Tuesday, March 6, 2018 at 3:01:07 PM UTC-5, thomasmu...@yahoo.com wrote:
Hi, is there a supported way to rename projects in gerrit?

I see there is a repo for this but no code in it https://gerrit.googlesource.com/plugins/rename-project/

--
--
To unsubscribe, email repo-discuss+unsubscribe@googlegroups.com

More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss+unsubscribe@googlegroups.com.

Duft Markus

unread,
Mar 7, 2018, 4:18:48 AM3/7/18
to chor...@wikimedia.org, Repo and Gerrit Discussion

For very large repositories (multiple GBs) even emptying the repo will retain it’s size, right? So somebody might clone the repo with the old URI, wait hours for the clone to complete (potentially), just to discover the OBSOLETE file – not quite optimal IMHO. Just adding my 2 cent, I don’t have real solutions at hand ;)

 

Cheers,

Markus

--
--
To unsubscribe, email repo-discuss...@googlegroups.com


More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


SSI Schäfer IT Solutions GmbH | Friesachstrasse 15 | 8114 Friesach | Austria
Registered Office: Friesach | Commercial Register: 49324 K | VAT no. ATU28654300
Commercial Court: Landesgericht für Zivilrechtssachen Graz

Luca Milanesio

unread,
Mar 7, 2018, 4:38:33 AM3/7/18
to Duft Markus, Luca Milanesio, chor...@wikimedia.org, Repo and Gerrit Discussion
If you actually copy the bare repo to the new name, the old one can be a "brand-new" repo with only the README in a single commit.
The history is preserved in the new one anyway.

Luca.

Hugo Arès

unread,
Aug 8, 2018, 9:08:02 AM8/8/18
to Repo and Gerrit Discussion
Let me revive this thread about rename plugin :)


On Tuesday, March 6, 2018 at 6:19:51 PM UTC-5, lucamilanesio wrote:
We had implemented in the past a "rename project" plugin and presented to Shawn ... but his objection was: how do you manage the situation where the same name is then reused with a new project?

The problem is the following:

T-0: Create project 'foo'

Change #1 created and merged against foo
URLs created and archived all around the place, including Jiras and CIs, pointing to foo

T-1: Rename project 'foo' to 'bar'

Change #1 needs to be updated in ReviewDb as all the 'foo' needs to become 'bar'
URLs in Gerrit pointing to 'foo' need to be redirected to 'bar'. Existing URLs will still work and will get a 302.

T-2: Create a new project 'foo'

Now ... what shall we do with 'foo'? Is that the "OLD" name to be redirected? or is the "NEW" project called 'foo'?

--- * ---

At the end of the day Shawn told me: can you explain to me the difference between rename project and create a new project with a new name and all the content of the old project and make the old project read-only and invisible?

The difference is if you do that, you do not have the changes in the new project, yes they are still in the old project but this is not good enough.

Now, for the changes URL redirection issue. We are still using 2.14, the URLs do not contain the project name so this is not an issue yet. I know I will have to find a solution for 2.15 and up but the question is we do have a working rename plugin for 2.14 so can I use the plugins/rename-project repo to push this to the open source?


Luca.

On 6 Mar 2018, at 20:52, Hugo Arès <hugo...@ericsson.com> wrote:

Currently, no.

As a workaround, you can always use the importer plugin and copy the project then delete
it with delete-project plugin. We are currently doing that but this is far from ideal, it takes a
very long time to "rename" projects when they have a lot of changes. Users keep working
on the source repo while copy is happening, you need to resume copy...and so on.

For this reason, we started to implement a rename-project plugin. So far, we have a
working proof of concept that renames projects which do not have children. The plugin is
based on 2.14.

I was planing to open source it eventually when we have a bit more done but maybe I
can open source it sooner if there is interest.

I checked the empty project on gerrit-review and it's owned by plugins-rename-project
group. Is there someone (Edwin?) who belongs to that group who could add me as a
member?

Hugo

On Tuesday, March 6, 2018 at 3:01:07 PM UTC-5, thomasmu...@yahoo.com wrote:
Hi, is there a supported way to rename projects in gerrit?

I see there is a repo for this but no code in it https://gerrit.googlesource.com/plugins/rename-project/

--
--

David Ostrovsky

unread,
Aug 8, 2018, 9:22:50 AM8/8/18
to Repo and Gerrit Discussion

Am Mittwoch, 8. August 2018 15:08:02 UTC+2 schrieb Hugo Arès:
Let me revive this thread about rename plugin :)

On Tuesday, March 6, 2018 at 6:19:51 PM UTC-5, lucamilanesio wrote:
We had implemented in the past a "rename project" plugin and presented to Shawn ... but his objection was: how do you manage the situation where the same name is then reused with a new project?

The problem is the following:

T-0: Create project 'foo'

Change #1 created and merged against foo
URLs created and archived all around the place, including Jiras and CIs, pointing to foo

T-1: Rename project 'foo' to 'bar'

Change #1 needs to be updated in ReviewDb as all the 'foo' needs to become 'bar'
URLs in Gerrit pointing to 'foo' need to be redirected to 'bar'. Existing URLs will still work and will get a 302.

T-2: Create a new project 'foo'

Now ... what shall we do with 'foo'? Is that the "OLD" name to be redirected? or is the "NEW" project called 'foo'?

--- * ---

At the end of the day Shawn told me: can you explain to me the difference between rename project and create a new project with a new name and all the content of the old project and make the old project read-only and invisible?

The difference is if you do that, you do not have the changes in the new project, yes they are still in the old project but this is not good enough.

Now, for the changes URL redirection issue. We are still using 2.14, the URLs do not contain the project name so this is not an issue yet. I know I will have to find a solution for 2.15 and up but the question is we do have a working rename plugin for 2.14 so can I use the plugins/rename-project repo to push this to the open source?`

Yes, please ;-) I already said this earlier in this thread:

Luca Milanesio

unread,
Aug 8, 2018, 9:49:29 AM8/8/18
to Hugo Arès, Luca Milanesio, Repo and Gerrit Discussion

On 8 Aug 2018, at 06:08, Hugo Arès <hug...@gmail.com> wrote:

Let me revive this thread about rename plugin :)

On Tuesday, March 6, 2018 at 6:19:51 PM UTC-5, lucamilanesio wrote:
We had implemented in the past a "rename project" plugin and presented to Shawn ... but his objection was: how do you manage the situation where the same name is then reused with a new project?

The problem is the following:

T-0: Create project 'foo'

Change #1 created and merged against foo
URLs created and archived all around the place, including Jiras and CIs, pointing to foo

T-1: Rename project 'foo' to 'bar'

Change #1 needs to be updated in ReviewDb as all the 'foo' needs to become 'bar'
URLs in Gerrit pointing to 'foo' need to be redirected to 'bar'. Existing URLs will still work and will get a 302.

T-2: Create a new project 'foo'

Now ... what shall we do with 'foo'? Is that the "OLD" name to be redirected? or is the "NEW" project called 'foo'?

--- * ---

At the end of the day Shawn told me: can you explain to me the difference between rename project and create a new project with a new name and all the content of the old project and make the old project read-only and invisible?

The difference is if you do that, you do not have the changes in the new project, yes they are still in the old project but this is not good enough.

Yes, I know, that's why we implemented the "rename project" plugin in the past :-)

Starting from Gerrit 2.15, the rename should be a lot easier because there is no reference to changes on ReviewDb and you simply rename the repo on the filesystem and reindex.


Now, for the changes URL redirection issue. We are still using 2.14, the URLs do not contain the project name so this is not an issue yet.

Sure, however the other old URLs wouldn't work anyway (pointers to Gitiles URLs and of course the clone URL).

I know I will have to find a solution for 2.15

Not really, 2.15 should work out of the box without plugins.

and up but the question is we do have a working rename plugin for 2.14 so can I use the plugins/rename-project repo to push this to the open source?

Sure, I believe it is a good idea :-)

Michelle Pogado

unread,
Aug 8, 2018, 9:50:02 AM8/8/18
to David Ostrovsky, Repo and Gerrit Discussion
+1 to reviving this thread.
We’re using 2.15 and importer plugin isn’t applicable to our use case :(

--
--
To unsubscribe, email repo-discuss...@googlegroups.com

Matthew Webber

unread,
Aug 8, 2018, 10:12:18 AM8/8/18
to Repo and Gerrit Discussion
On Wednesday, 8 August 2018 14:49:29 UTC+1, lucamilanesio wrote:
Starting from Gerrit 2.15, the rename should be a lot easier because there is no reference to changes on ReviewDb and you simply rename the repo on the filesystem and reindex 

Wow, of course. All the metadata is in the repo itself.
What about the case where I delete the repo on the filesystem, and reindex? I presume that doesn't work, but why not?

Luca Milanesio

unread,
Aug 8, 2018, 10:21:41 AM8/8/18
to Matthew Webber, Luca Milanesio, Repo and Gerrit Discussion
You mean for the "delete repository" scenario? That should work as well.

One thing I forgot to mention is the cache cleanup.

The full sequence with Gerrit 2.15 is:
- rename (or remove) the repository
- flush caches (projects, project_list)
- reindex

... and it works like a charm :-)

*LOVE* NoteDb ! A very good reason for upgrading right now to Gerrit 2.15.
We got so much latency reduction on GerritHub.io since we migrated to NoteDb.

Luca.

Hugo Arès

unread,
Aug 8, 2018, 2:28:42 PM8/8/18
to Repo and Gerrit Discussion

Done, here is the implementation we use in production in Gerrit 2.14: https://gerrit-review.googlesource.com/c/plugins/rename-project/+/192050
 

Luca Milanesio

unread,
Aug 8, 2018, 2:29:38 PM8/8/18
to Hugo Arès, Luca Milanesio, Repo and Gerrit Discussion
Sounds good :-) Thanks for sharing it.

Luca.

Richard Christie

unread,
Aug 8, 2018, 4:38:20 PM8/8/18
to Repo and Gerrit Discussion
On Wednesday, 8 August 2018 15:21:41 UTC+1, lucamilanesio wrote:

You mean for the "delete repository" scenario? That should work as well.

One thing I forgot to mention is the cache cleanup.

The full sequence with Gerrit 2.15 is:
- rename (or remove) the repository
- flush caches (projects, project_list)
- reindex

... and it works like a charm :-)

*LOVE* NoteDb ! A very good reason for upgrading right now to Gerrit 2.15.
We got so much latency reduction on GerritHub.io since we migrated to NoteDb.

Luca.

One thing you omit which I noticed when renaming since 2.13 (also very happy this is now much easier in 2.15 and noteDb than it was with reviewDb) was that the refs/notes/review magic branch contains a reference to the old repository name. Not sure whether this matters, but I wrote a script to go through all the commits on that and replay them with the correct 'new' name. 

Does it actually matter - does gerrit use that information itself for anything? 

Jonathan Nieder

unread,
Aug 8, 2018, 4:43:29 PM8/8/18
to Richard Christie, Repo and Gerrit Discussion
> Does it actually matter - does gerrit use that information itself for anything? 

Gerrit does not use that information itself for anything. It's informational, for end users.

That means you can't go wrong either way (by rewriting or not rewriting). :)

Jonathan

ср, 8 авг. 2018 г. в 13:38, Richard Christie <r.d.f.c...@gmail.com>:
--
Reply all
Reply to author
Forward
0 new messages