How to upload android source code to Gerrit and make a branch/tag of it?

1,579 views
Skip to first unread message

Trung Chính Mai

unread,
Dec 30, 2014, 11:50:05 AM12/30/14
to repo-d...@googlegroups.com
Dear All,
I have just learned about Git, Gerrit for a week and I very need your help about two works that I cannot solve:
1. I "repoed" Google Source Code project (repo init -u https://android.googlesource.com/platform/manifest). Now, I want to upload this Google Source Code project to my Gerrit server and keep its history because my colleagues aslo want to use it or its branchs (like android 4.3, android 4.4.4 or android 5.0 etc..). In Gerrit, I created projects as in manifest.xml in .repo (like platform/developers/build, platform/developers/samples/android, etc ..). How should I do this work?
2. The way to create a branch or a tag like Mymodandroid (to "repo sync" from "repo init -u https://android.googlesource.com/platform/manifest -b Mymodandroid ), for example, the way that Google made android-4.0.1_r1 tag. I tried to use "repo forall -c git tag -a Mymodandroid " command but this way tags this tag to every project, I checked Google Source Code and did not see this phenomenon.
Thanks and Best Regards,
Mai

李大明

unread,
Jan 1, 2015, 8:21:23 AM1/1/15
to repo-d...@googlegroups.com
Try the following steps to clone your private AOSP mirror.

1. repo init -u  repo init -u https://android.googlesource.com/mirror/manifest --mirror
    repo sync -j4

    Add --mirror to keep all git structure from remote

    platform/manifest only contains repository current version use, platform/manifest contains all repositories used in the past release.
    New repositories will be added when Android upgrades its version, 
    you must add new repositories manually if you want upgrade your Android in the future.

2. Create a parent project "mirror-project-permission-base" as the permission base of all your android 

2. repo forall -c 'ssh -p PORT ACCOUNT@SERVER gerrit create-project PROJECT_ROOT/$REPO_PROJECT;'
    repo forall -c 'ssh -p PORT ACCOUNT@SERVER gerrit set-project-parent --parent mirror-project-permission-base PROJECT_ROOT/$REPO_PROJECT'
    repo forall -c 'git push ssh://ACCOUNT@SERVER:PORT/PROJECT_ROOT/$REPO_PROJECT 'refs/heads/*' 'refs/tags/*' 'refs/notes/*''

    This is use repo to create projects by your local project names on server, set their parent permission, and push local content to remote.

3. Create your own manifest project. 

Trung Chính Mai於 2014年12月31日星期三UTC+8上午12時50分05秒寫道:

Trung Chính Mai

unread,
Jan 1, 2015, 10:21:28 AM1/1/15
to repo-d...@googlegroups.com
Thank you so much, 李大明
By the way, happy new year.
Vào 20:21:23 UTC+7 Thứ năm, ngày 01 tháng một năm 2015, 李大明 đã viết:

李大明

unread,
Jan 1, 2015, 11:18:05 AM1/1/15
to repo-d...@googlegroups.com
By the way, when you create your own manifest, you have to refer to platform/manifest.

https://android.googlesource.com/platform/manifest/

Modify default.xml of the the version of Android and point the fetch/review URL and put it in your own git repository.
When run repo init, point the URL to your own repository. That should do the work.

Trung Chính Mai於 2015年1月1日星期四UTC+8下午11時21分28秒寫道:

Trung Chính Mai

unread,
Jan 1, 2015, 11:50:20 AM1/1/15
to repo-d...@googlegroups.com
Dear 李大明,
I have just did things that you mentioned above but can you tell me what should I place at "
PROJECT_ROOT/$REPO_PROJECT" variable? I replaced "PROJECT_ROOT/$REPO_PROJECT" with a specific project name (not android) and implemented command without "repo forall -c ..", it worked. But with whole android, with many projects, must to use "repo forall -c ..", I don't know which one to place at "PROJECT_ROOT/$REPO_PROJECT" variable.
Thanks and best regards,

李大明

unread,
Jan 1, 2015, 8:05:12 PM1/1/15
to repo-d...@googlegroups.com
When you run repo 'for all -c'  in the android repo repository you cloned from AOSP, you do the command for all projects one by one.  When repo iteratorly  run  'ssh -p PORT ACCOUNT@SERVER gerrit create-project PROJECT_ROOT/$REPO_PROJECT;', it replaces $REPO_PROJECT with the current project name. 

Say, for the project platform/system/vold, the command is 

 ssh -p PORT ACCOUNT@SERVER gerrit create-project PROJECT_ROOT/platform/system/vold'

Check here to see what $REPO_PROJECT is https://source.android.com/source/using-repo.html

PROJECT_ROOT is the parent folder to keep all android projects into one place for easy management.
The benefit is if you want to delete all Android related projects, just go to the git folder in your gerrit server and delete the PROJECT_ROOT. This is not necessary but make your management easier. 

Trung Chính Mai於 2015年1月2日星期五UTC+8上午12時50分20秒寫道:

Trung Chính Mai

unread,
Jan 1, 2015, 8:58:47 PM1/1/15
to repo-d...@googlegroups.com
Thanks, I got it. As what I understood, I'm confuse about the implementing how to create over 400 projects in Android, it may be take a lot of time. Is there way to these 400 projects in a command with " forall" meaning?

李大明

unread,
Jan 1, 2015, 11:58:56 PM1/1/15
to repo-d...@googlegroups.com
I don't really got what you mean. 

You can use 'repo list' to see how many projects. With 'repo forall -c', you can execute a command in every git projects.

Trung Chính Mai於 2015年1月2日星期五UTC+8上午9時58分47秒寫道:

Trung Chính Mai

unread,
Jan 2, 2015, 3:07:40 AM1/2/15
to repo-d...@googlegroups.com
Sorry because of my expression.
I want to manage Android source code like the way Google do, that means I divide Android into over 400 projects (list in manifest.xml as platform/abi/cpp, platform/art, platform/bootable/recovery, etc ..). Like your example " ssh -p PORT ACCOUNT@SERVER gerrit create-project PROJECT_ROOT/platform/system/
vold" but how about remainded projects (400 projects)? It will be take a lot of time to create each project so I want to need your help about this. I downloaded Android source code mirror (repo init -u https://android.googlesource.com/mirror/manifest --mirror), please help me the way to create over 400 projects (as content of manifest.xml) with a "repo forall -c ssh -p PORT ACCOUNT@SERVER gerrit create-project ???/?????".


Vào 11:58:56 UTC+7 Thứ sáu, ngày 02 tháng một năm 2015, 李大明 đã viết:
Message has been deleted

李大明

unread,
Jan 2, 2015, 3:53:12 AM1/2/15
to repo-d...@googlegroups.com
Switch to the folder you just repo from AOSP.

repo forall -c 'ssh -p PORT ACCOUNT@SERVER gerrit create-project PROJECT_ROOT/$REPO_PROJECT;'

Because repo forall means going to the path of each project and do the command.The $REPO_PROJECT will be replaced by that project name.
What you do is create projects according to the projects' name in your local AOSP code base.

So you can complete 400 projects' creation in one shot.

Trung Chính Mai於 2015年1月2日星期五UTC+8下午4時07分40秒寫道:

Trung Chính Mai

unread,
Jan 3, 2015, 3:48:26 AM1/3/15
to repo-d...@googlegroups.com
I really do thank you so much. I did it.
Reply all
Reply to author
Forward
0 new messages