Best practices for working with gerrit and an aosp mirror

2,240 views
Skip to first unread message

David Linares

unread,
Nov 5, 2017, 7:08:09 AM11/5/17
to Repo and Gerrit Discussion
Hi all,
I am currently setting up all the infra needed for developers to contribute to an aosp-based project and would need your advice. 
Here is what I have done so far:
  1. Set-up a gerrit server (gerrit.myserver.com)
  2. Ssh to gerrit.myserver.com and create a local aosp mirror on the gerrit server
    cd aosp/mirror
    repo init -u https://android.googlesource.com/mirror/manifest --mirror
    repo sync
  3. Log in to gerrit.myserver.com and create all the branches and tags to gerrit
    cd aosp/mirror
    repo forall -c 'echo $REPO_PATH; ssh -p 29418 admin@localhost gerrit create-project --name aosp/$REPO_PATH --owner aosp --parent aosp;'
    repo forall -c 'echo $REPO_PATH; git push ssh://admin@localhost:29418/aosp/$REPO_PATH +refs/heads/* +refs/tags/*;'
Now, I am a bit confused to what needs to be done from that point for developers.
Say they need to work on a branch off the tag android-7.0.0_r1.
Am I correct in thinking that I would first need to do the following for them:
  1.  Log in to my developer machine and create that branch for them, under a different namespace, so that it doesn't mix with upstream stuff
    cd my_empty_dir
    repo init -u ssh://admin@localhost:29418/aosp/platform/manifest -b android-7.0.0_r1
    (do I need to sync? was the previous command to be run on the local mirror instead?  )
    repo forall -c 'echo $REPO_PATH; ssh -p 29418 ad...@gerrit.myserver.com gerrit create-branch aosp/$REPO_PATH devel-android-7.0.0_r1 android-7.0.0_r1;'

  2. Make a first commit to the aosp/platform/manifest to modify default.xml to have the fetch and review URL pointing to gerrit.myserver.com
  3. Ask a developer to check if they can run "repo init -u ssh://user...@gerrit.myserver.com:29418/aosp/platform/manifest -b devel-android-7.0.0_r1"
Thought I would ask before doing anything stupid.
Still very confused with what needs to be done on the server (I am assuming only running repo sync on the local mirror to take new code) and what should be done on a developer machine (creating branches, committing code, etc...).

Thanks a lot in advance for your help.
Kind regards,
David

David Linares

unread,
Nov 8, 2017, 9:41:58 AM11/8/17
to Repo and Gerrit Discussion
Hi again,

I have done a few experiments and found that the following procedure seems to work:
    1. Set-up a gerrit server (gerrit.myserver.com)
    2. Ssh to gerrit.myserver.com and create a local aosp mirror on the gerrit server
      cd aosp/mirror
      repo init -u https://android.googlesource.com/mirror/manifest --mirror
      repo sync
    3. Log in to gerrit.myserver.com and create all the branches and tags to gerrit
      cd aosp/mirror
      repo forall -c 'echo $REPO_PATH; ssh -p 29418 admin@localhost gerrit create-project --name aosp/$REPO_PATH --owner aosp --parent aosp;'
      repo forall -c 'echo $REPO_PATH; git push ssh://admin@localhost:29418/aosp/$REPO_PATH +refs/heads/* +refs/tags/*;'
    1. Create the new development branch directly from the mirror code
      cd aosp/mirror
      repo forall -c 'echo $REPO_PATH; ssh -p 29418 admin@localhost gerrit create-branch aosp/$REPO_PATH develnamespace/android-7.0.0_r1 android-7.0.0_r1;'
    2. Log to a developer machine to change the manifest
      cd my_empty_dir
      repo init -u ssh://user...@gerrit.myserver.com:29418/aosp/platform/manifest -b develnamespace/android-7.0.0_r1
      cd .repo/manifests/
      vi default.xml
          - fetch=".." />
          + fetch=".."
          + review="http://gerrit.myserver.com/" />

          - <default revision="refs/heads/develnamespace/android-7.0.0_r1"
          + <default revision="refs/tags/android-7.0.0_r1"

      git add default.xml
      git commit -s -m "Add review URL and branch name to the manifest"
      git push
      ssh://user...@gerrit.myserver.com:29418/aosp/platform/manifest HEAD:refs/for/refs/heads/develnamespace/android-7.0.0_r1
    3. Go to Gerrit web UI and merge the new change
    From that point onward, I am guessing/hoping :-) that a developer will be able to develop using the Android workflow by doing something like
    • repo init -u ssh://user...@gerrit.myserver.com:29418/aosp/platform/manifest -b develnamespace/android-7.0.0_r1
    • repo sync
    • repo start mynewfeature --all
    • edit some files
    • git add <some files>
    • git commit -s -m "Added my new feature"
    • repo upload
    Would really appreciate on getting some feedback on the above steps, as I am pretty sure they are not optimal or the best way to work with gerrit and an aosp mirror.

    Thank you very much.
    Kind regards,
    David



    On Sunday, 5 November 2017 12:08:09 UTC, David Linares wrote:
    Hi all,
    I am currently setting up all the infra needed for developers to contribute to an aosp-based project and would need your advice. 
    Here is what I have done so far:
    1. Set-up a gerrit server (gerrit.myserver.com)
    2. Ssh to gerrit.myserver.com and create a local aosp mirror on the gerrit server
      cd aosp/mirror
      repo init -u https://android.googlesource.com/mirror/manifest --mirror
      repo sync
    3. Log in to gerrit.myserver.com and create all the branches and tags to gerrit
      cd aosp/mirror
      repo forall -c 'echo $REPO_PATH; ssh -p 29418 admin@localhost gerrit create-project --name aosp/$REPO_PATH --owner aosp --parent aosp;'
      repo forall -c 'echo $REPO_PATH; git push ssh://admin@localhost:29418/aosp/$REPO_PATH +refs/heads/* +refs/tags/*;'
    Now, I am a bit confused to what needs to be done from that point for developers.
    Say they need to work on a branch off the tag android-7.0.0_r1.
    Am I correct in thinking that I would first need to do the following for them:
    1.  Log in to my developer machine and create that branch for them, under a different namespace, so that it doesn't mix with upstream stuff
      cd my_empty_dir
      repo init -u ssh://admin@localhost:29418/aosp/platform/manifest -b android-7.0.0_r1
      (do I need to sync? was the previous command to be run on the local mirror instead?  )
      repo forall -c 'echo $REPO_PATH; ssh -p 29418 ad...@gerrit.myserver.com gerrit create-branch aosp/$REPO_PATH devel-android-7.0.0_r1 android-7.0.0_r1;'

    2. Make a first commit to the aosp/platform/manifest to modify default.xml to have the fetch and review URL pointing to gerrit.myserver.com
    1. Ask a developer to check if they can run "repo init -u ssh://username@gerrit.myserver.com:29418/aosp/platform/manifest -b devel-android-7.0.0_r1"
    Thought I would ask before doing anything stupid.
    Still very confused with what needs to be done on the server (I am assuming only running repo sync on the local mirror to take new code) and what should be done on a developer machine (creating branches, committing code, etc...).

    David Linares

    unread,
    Nov 13, 2017, 11:32:28 AM11/13/17
    to Repo and Gerrit Discussion
    Hi all,

    Using a namespace for anything coming from upstream might not be a great idea after all...
    I am having an issue when doing a repo upload.
    Looking at the ReviewUrl function in .repo/repo/git_config.py, it looks like it creates the url without my "aosp" namespace, which would explain why I am getting the following error:

    : git push --receive-pack=gerrit receive-pack ssh://user...@gerrit.myserver.com:29418/platform/system/sepolicy refs/heads/mynewfeature:refs/for/develnamespace/android-7.0.0_r1 1>| 2>|
    fatal: Project not found: platform/system/sepolicy
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

    Not sure how to solve that issue so that it resolves the url as ssh://user...@gerrit.myserver.com:29418/aosp/platform/system/sepolicy and not ssh://user...@gerrit.myserver.com:29418/platform/system/sepolicy.
    Hope I don't have to update the Manifest to change all the project names...

    Thanks a lot.
    David


    On 8 November 2017 at 14:41, David Linares <dlinare...@gmail.com> wrote:
    Hi again,

    I have done a few experiments and found that the following procedure seems to work:
    1. Set-up a gerrit server (gerrit.myserver.com)
    2. Ssh to gerrit.myserver.com and create a local aosp mirror on the gerrit server
      cd aosp/mirror
      repo init -u https://android.googlesource.com/mirror/manifest --mirror
      repo sync
    3. Log in to gerrit.myserver.com and create all the branches and tags to gerrit
      cd aosp/mirror
      repo forall -c 'echo $REPO_PATH; ssh -p 29418 admin@localhost gerrit create-project --name aosp/$REPO_PATH --owner aosp --parent aosp;'
      repo forall -c 'echo $REPO_PATH; git push ssh://admin@localhost:29418/aosp/$REPO_PATH +refs/heads/* +refs/tags/*;'
    4. Create the new development branch directly from the mirror code
      cd aosp/mirror
      repo forall -c 'echo $REPO_PATH; ssh -p 29418 admin@localhost gerrit create-branch aosp/$REPO_PATH develnamespace/android-7.0.0_r1 android-7.0.0_r1;'
    1. Log to a developer machine to change the manifest
      cd my_empty_dir
    1. repo init -u ssh://username@gerrit.myserver.com:29418/aosp/platform/manifest -b develnamespace/android-7.0.0_r1

    1. cd .repo/manifests/
      vi default.xml
          - fetch=".." />
          + fetch=".."
          + review="http://gerrit.myserver.com/" />

          - <default revision="refs/heads/develnamespace/android-7.0.0_r1"
          + <default revision="refs/tags/android-7.0.0_r1"

    1. git add default.xml
      git commit -s -m "Add review URL and branch name to the manifest"
    1. git push ssh://username@gerrit.myserver.com:29418/aosp/platform/manifest HEAD:refs/for/refs/heads/develnamespace/android-7.0.0_r1
    1. Go to Gerrit web UI and merge the new change
    From that point onward, I am guessing/hoping :-) that a developer will be able to develop using the Android workflow by doing something like
    1. Ask a developer to check if they can run "repo init -u ssh://user...@gerrit.myserver.com:29418/aosp/platform/manifest -b devel-android-7.0.0_r1"
    Thought I would ask before doing anything stupid.
    Still very confused with what needs to be done on the server (I am assuming only running repo sync on the local mirror to take new code) and what should be done on a developer machine (creating branches, committing code, etc...).

    Thanks a lot in advance for your help.
    Kind regards,
    David

    --
    --
    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.
    For more options, visit https://groups.google.com/d/optout.

    Sven Selberg

    unread,
    Nov 14, 2017, 3:40:46 AM11/14/17
    to Repo and Gerrit Discussion
    You could take a look at configuring pushInsteadOf.

    https://git-scm.com/docs/git-push#_git_urls_a_id_urls_a

    /Sven

    On Monday, November 13, 2017 at 5:32:28 PM UTC+1, David Linares wrote:
    Hi all,

    Using a namespace for anything coming from upstream might not be a great idea after all...
    I am having an issue when doing a repo upload.
    Looking at the ReviewUrl function in .repo/repo/git_config.py, it looks like it creates the url without my "aosp" namespace, which would explain why I am getting the following error:

    : git push --receive-pack=gerrit receive-pack ssh://username@gerrit.myserver.com:29418/platform/system/sepolicy refs/heads/mynewfeature:refs/for/develnamespace/android-7.0.0_r1 1>| 2>|

    fatal: Project not found: platform/system/sepolicy
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

    Not sure how to solve that issue so that it resolves the url as ssh://username@gerrit.myserver.com:29418/aosp/platform/system/sepolicy and not ssh://username@gerrit.myserver.com:29418/platform/system/sepolicy.
    Thanks a lot.
    David


    1. Ask a developer to check if they can run "repo init -u ssh://username@gerrit.myserver.com:29418/aosp/platform/manifest -b devel-android-7.0.0_r1"
    Thought I would ask before doing anything stupid.
    Still very confused with what needs to be done on the server (I am assuming only running repo sync on the local mirror to take new code) and what should be done on a developer machine (creating branches, committing code, etc...).

    Thanks a lot in advance for your help.
    Kind regards,
    David

    --
    --
    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.
    Reply all
    Reply to author
    Forward
    0 new messages