Rename a Gerrit Project - version 2.4.2

8,244 views
Skip to first unread message

Jen

unread,
Nov 9, 2012, 2:10:07 PM11/9/12
to repo-d...@googlegroups.com
 Could you pl let me know how to correctly rename a  Gerrit Code Review (2.4.2) project?

Shawn Pearce

unread,
Nov 9, 2012, 2:33:00 PM11/9/12
to Jen, repo-discuss
On Fri, Nov 9, 2012 at 11:10 AM, Jen <jstan...@gmail.com> wrote:
> Could you pl let me know how to correctly rename a Gerrit Code Review
> (2.4.2) project?

I think you can do:

$ cd $site_path/git;
$ mv old_name.git new_name.git

$ ssh -P 29418 localhost gerrit gsql
UPDATE changes SET dest_project_name = 'new_name' WHERE
dest_project_name = 'old_name';

Jen

unread,
Nov 9, 2012, 6:23:18 PM11/9/12
to repo-d...@googlegroups.com
Hi Shawn,
 
I created a test gerrit project, and renamed it. (mv old_name.git new_name.git)
 
However, I do not see anything under the changes table. So, the UPDATE would not work.
 
Thanks!

Shawn Pearce

unread,
Nov 9, 2012, 6:38:25 PM11/9/12
to Jen, repo-discuss
On Fri, Nov 9, 2012 at 3:23 PM, Jen <jstan...@gmail.com> wrote:
> I created a test gerrit project, and renamed it. (mv old_name.git
> new_name.git)
>
> However, I do not see anything under the changes table. So, the UPDATE would
> not work.

It won't fail either.

The update is necessary to correct any prior or pending code reviews.
If you have no code reviews (e.g. brand new repository) then there is
nothing to update.

Jen

unread,
Nov 10, 2012, 12:52:02 AM11/10/12
to repo-d...@googlegroups.com, Jen
After I rename the project and login to gerrit,  I don't even see the project name(old/new) under list of projects.

Edwin Kempin

unread,
Nov 10, 2012, 10:15:01 AM11/10/12
to Jen, repo-d...@googlegroups.com


2012/11/10 Jen <jstan...@gmail.com>

After I rename the project and login to gerrit,  I don't even see the project name(old/new) under list of projects.
You also need to flush the prjects cache [1] or restart Gerrit.

[1] https://gerrit-review.googlesource.com/Documentation/cmd-flush-caches.html

 
 

 
 

On Friday, November 9, 2012 3:38:50 PM UTC-8, Shawn Pearce wrote:
On Fri, Nov 9, 2012 at 3:23 PM, Jen <jstan...@gmail.com> wrote:
> I created a test gerrit project, and renamed it. (mv old_name.git
> new_name.git)
>
> However, I do not see anything under the changes table. So, the UPDATE would
> not work.

It won't fail either.

The update is necessary to correct any prior or pending code reviews.
If you have no code reviews (e.g. brand new repository) then there is
nothing to update.

Leoš Junek

unread,
Oct 24, 2014, 5:30:47 AM10/24/14
to repo-d...@googlegroups.com, jstan...@gmail.com
My Gerrit version is 2.9. I'm facing the same problem as Jen - I cannot see any open / merged /abandoned changes after renaming the project in Gerrit change table

My steps to rename project:
1. rename folder on filesystem of Gerrit server
mv -v oldname.git newname.git

2. login to H2 database CLI
ssh -p 29418 admin@machine gerrit gsql

3. update tables ACCOUNT_PROJECT_WATCHES and CHANGES
gsql> UPDATE ACCOUNT_PROJECT_WATCHES SET PROJECT_NAME='newname' WHERE PROJECT_NAME='oldname';
gsql> UPDATE CHANGES SET DEST_PROJECT_NAME='newname' WHERE DEST_PROJECT_NAME='oldname';

4. flush project caches
ssh -p 29418 admin@machine gerrit flush-caches -all

Project is visible in list of all projects, but there are no changes concerning this project in menu All > Open | Merged | Abandoned, or My > Changes.

Something is wrong in the process of renaming....

What about you, did anyone manage to rename project and see its changes in Gerrit GUI?


Leoš


Dne pátek, 9. listopadu 2012 20:10:07 UTC+1 Jen napsal(a):
 Could you pl let me know how to correctly rename a  Gerrit Code Review (2.4.2) project?

Dne sobota, 10. listopadu 2012 16:15:05 UTC+1 Edwin Kempin napsal(a):

Leoš Junek

unread,
Oct 24, 2014, 5:50:48 AM10/24/14
to repo-d...@googlegroups.com, jstan...@gmail.com
To overcome mentioned problem reindex is needed :-)

5. perform reindex
stop Gerrit
java -jar /home/gerrit2/review_site/bin/gerrit.war reindex -d /home/gerrit2/review_site
start Gerrit


Dne pátek, 24. října 2014 11:30:47 UTC+2 Leoš Junek napsal(a):

Leoš Junek

unread,
Jan 14, 2015, 10:26:56 AM1/14/15
to repo-d...@googlegroups.com

Hello to all,

 

here are my steps to rename Gerrit projects in Gerrit version 2.9(.0) performed in linux command line.

 

Lets say your project to rename is called projecttorename.old and you like to change its name to projecttorename.new. 

 

1. Check submodules

Discover whether project projecttorename.old is submodule of other projects. If so, you have to modify submodule configuration of these affected projects (it's stored in file .gitmodules). Submodule is a project that is linked to another project and that project in fact depends on its submodule. If you rename submodule and not configuration of dependent project, then that dependent project could not be cloned with module any more.

 

So check if project servers as submodule to  I have not an idea how to do it gently and easily, so all projects were cloned and file .gitmodules was searched in root directory of these projects. If it referred to projecttorename.old, then projecttorename.old was a submodule.

 

 

2. Check permission inheritance

Does other projects inherit permissions from your projecttorename.old? If so, do not forget to update it after end of renaming.

 

To see inheritance tree try

ssh -p 29418 adminusername@gerrit-hostname gerrit ls-projects --tree

 

Could you see projecttorename.old as a leaf in that graph with no another project inheritting from it? If so, it's OK. However, if another project (e.g. projectA) depends on projecttorename.old, you will have to update  configuration of permissions of projectA at the end of the process.

 

Here there are two ways for renaming project: 

NO-SUBMODULES (the project projecttorename.old is not a submodule of other projects and there are no submodules defined in the project) and WITH-SUBMODULES (project projecttorename.old is either submodule or there are some submodules defined inside it)

 

NO-SUBMODULES WAY

No submodules, no code review.

3. Update of project name in Gerrit database 

Here shown for internal H2 database. You have to update tables ACCOUNT_PROJECT_WATCHES a CHANGES

 

UPDATE ACCOUNT_PROJECT_WATCHES SET PROJECT_NAME='projecttorename.new' WHERE PROJECT_NAME='projecttorename.old';

UPDATE CHANGES SET DEST_PROJECT_NAME
='projecttorename.new' WHERE DEST_PROJECT_NAME='projecttorename.old';


 

 

4. Rename directory on filesystem of Gerrit server

cd /path/to/repository/base
mv projecttorename
.old.git projecttorename.new.git

 

5. Flush Gerrit cache

ssh -p 29418 adminusername@gerrit-hostname gerrit flush-caches --all


6. Reindexing of Gerrit

Stop Gerrit.

java -jar /home/gerrit/review_site/bin/gerrit.war reindex -d /home/gerrit/review_site

Start Gerrit.

 

7. Update permission inheritance (Rights Inherit From), if necessary 

Web UI > Projects > Select projecttorename.new > Access > Edit

 

8. Optional: Clone project

To verify your project was renamed, clone it (projecttorename.new) to your local machine.

 

 

WITH-SUBMODULES 

Let's assume the most complicated case: you rename both 

commontorename.old (common projects with submodule submoduletorename.old project) and 

submoduletorename.old to new names. Your project commontorename.old is configured that all changes must be reviewed with code-review functionality to be merged on remote server.

 

3. Clone commontorename.old to local disk

 

4. Update submodule URL

Open file commontorename.old/.gitmodules and update URL of submodule.

 

Example:

[submodule "shared"]
 path
= sharedlibs
 url
= ssh://gerrit.company.com/submoduletorename.old

after update

[submodule "shared"]
 path
= sharedlibs
 url
= ssh://gerrit.company.com/submoduletorename.new


5. Install hook commit-msg just to add Change-Id tag

Change-Id in commit message is necessary for accepting change to code review.

cd /path/to/localrepobase/
cd commontorename
.old
scp
-p -P 29418 admin@gerrit.company.com:hooks/commit-msg .git/hooks/


6. Rename submodule project

According to NO-SUBMODULES scheme, rename 

submoduletorename.old to submoduletorename.new

7. Grant permissions for code-review of project commontorename.old
To be able to perform Code-Review to merge new .gitmodules into remote repository you have to grant permissions for yourself (assume you are administrator) to be independent on other users of the project. Being administrator does not mean you are allowed to Verify, Code-Review and Submit.

8. Commit changed .gitmodule to local & remote repo, pull changes

cd commontorename.old
git add
.gitmodules
git commit
-m "Submodule URL update"
git push
--progress origin refs/heads/master:refs/for/master

At this point perform code review of change at Gerrit web UI, including Submit.

To be sure all changes are merged on remote server, you can perform fetch and show git status
git fetch --progress origin
git status

Now project commontorename.old contains valid submodule path. It can be renamed without any worries.

9. Update of Gerrit database tables
Here shown for internal H2 database. You have to update tables ACCOUNT_PROJECT_WATCHES a CHANGES

UPDATE ACCOUNT_PROJECT_WATCHES SET PROJECT_NAME='commontorename.new' WHERE PROJECT_NAME='commontorename.old';

UPDATE CHANGES SET DEST_PROJECT_NAME
='commontorename.new' WHERE DEST_PROJECT_NAME='commontorename.old';

10. Rename of project folder on filesystem
cd /path/to/repository/base
mv commontorename
.old.git commontorename.new.git

11. Flush Gerrit cache

ssh -p 29418 adminusername@gerrit-hostname gerrit flush-caches --all

12. Reindexing of Gerrit

Stop Gerrit.

java -jar /home/gerrit/review_site/bin/gerrit.war reindex -d /home/gerrit/review_site

Start Gerrit.


13. Testing of success of operation

Clone both commontorename.new and submoduletorename.new


14. Fixing of inheritance of permission
If another project inherits access rights from either commontorename.old or submoduletorename.old, change it in project config (menu Access) to commontorename.new or submoduletorename.new. 

15. Remove of permissions for administrator to Code-Review, Verify, Submit
If some special permissions were assigned to administrator in commontorename.old project, now is the time to revert it.

Hope it helps.

Leoš


Dne pátek 9. listopadu 2012 20:10:07 UTC+1 Jen napsal(a):

Ramkumar D

unread,
Mar 6, 2015, 3:00:54 AM3/6/15
to repo-d...@googlegroups.com, jstan...@gmail.com
Hi,

The index command was failing with below error message.

fatal: index.type must be configured (or not SQL)

How to resolve this? 

Note: No index type specified in the gerrit.config file.

Regards,
Ram

David Pursehouse

unread,
Mar 6, 2015, 5:05:14 AM3/6/15
to Ramkumar D, repo-d...@googlegroups.com, jstan...@gmail.com
On 03/06/2015 05:00 PM, Ramkumar D wrote:
> Hi,
>
> The index command was failing with below error message.
>
> fatal: index.type must be configured (or not SQL)
>
> How to resolve this?
>
> Note: No index type specified in the gerrit.config file.
>

No index type specified means it's defaulting to SQL, which effectively
means no secondary index. The reindex program does not work when the
secondary index is not enabled.

I suppose this is on 2.8.x because since 2.9 the index defaults to Lucene.

Documentation for 2.8 is here. Search for "Section index".

https://gerrit-documentation.storage.googleapis.com/Documentation/2.8/config-gerrit.html



> Regards,
> Ram
>
> On Friday, October 24, 2014 at 3:20:48 PM UTC+5:30, Leoš Junek wrote:
>
> To overcome mentioned problem reindex is needed :-)
>
> *5. perform reindex*
> stop Gerrit
> java -jar /home/gerrit2/review_site/bin/gerrit.war reindex -d
> /home/gerrit2/review_site
> start Gerrit
>
>
> Dne pátek, 24. října 2014 11:30:47 UTC+2 Leoš Junek napsal(a):
>
> My Gerrit version is 2.9. I'm facing the same problem as Jen - I
> cannot see any open / merged /abandoned changes after renaming
> the project in Gerrit change table
>
> My steps to rename project:
> *1. rename folder on filesystem of Gerrit server*
> mv -v oldname.git newname.git
>
> *2. login to H2 database CLI*
> ssh -p 29418 admin@machine gerrit gsql
>
> *3. update tables ACCOUNT_PROJECT_WATCHES and CHANGES*
> gsql> UPDATE ACCOUNT_PROJECT_WATCHES SET PROJECT_NAME='newname'
> WHERE PROJECT_NAME='oldname';
> gsql> UPDATE CHANGES SET DEST_PROJECT_NAME='newname' WHERE
> DEST_PROJECT_NAME='oldname';
>
> *4. flush project caches*
> <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
> <mailto:repo-discuss...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages