Git server-side information

Introduction

This guide contains some helpful recipes for the git source control tool that may be useful to developers working in Chromium OS.  The recipes here are focused on tasks related to maintaining the git server / adding new projects.

Related pages:


How do I create a new repository on the git server?

  1. Talk to relevant people on IRC or the chromium-os-dev mailing list to make sure it's ok to add the new repositories
  2. Open a "Build Infrastructure" bug at http://crbug.com/new  to request the repository be created and who has access to it. If you are not a committer, please include the email address of a committer/sponsor who is working with you in the bug. Note that Build Infrastructure bugs are marked private to the build team and the reporter.

Tips for getting your new repo created with minimal fuss:

  • Be clear in the bug title that you are requesting a new git repo. 
  • Say whether it should be on chromium.googlesource.com (public) or chrome-internal.googlesource.com (not public).
  • Provide a project path and name for the new repository. For public repos, the path should start with /chromiumos/. For private repos, the path should start with /chromeos/. Look at existing projects in git or git-internal for precedents on the path to use.
  • Note: You don't need to go into too much detail about why the repo is needed.

How do I add files to a new repository on the git server?

Do this OUTSIDE your local chromiumos source tree.  You will not be adding the files directly, but starting by adding them via a Gerrit CL.  Once the CL is uploaded and reviewed, you can use Gerrit to complete pushing the CL into the repository.

You'll want to set the repo shell variable to the name of your repository (e.g. trunks) before starting, and repo-path to the full server-side path (e.g. chromiumos/platform/trunks.git).

mkdir ${repo}
cp -rp /my/repo/seed/contents/* ${repo}
cd ${repo}
git init
git add .
git commit -am "init repo"

# somelabel is just a throwaway pointer (name) used between the following 2 commands
git remote add somelabel https://chromium-review.googlesource.com/${repo-path}
git push somelabel HEAD:refs/for/master  # Creates Gerrit Issue

IMPORTANT: One of your files should be a README.chromium file.  Another should probably be a LICENSE file, which is pointed to by the README.chromium file. (Note: This applies mostly to local copies of upstream repos, typically in src/third-party.  We don't seem to follow this rule for repos in src/platform.)


How do I create a new branch on the git server?

IMPORTANT: Only authorized server branch owners can do this. You know who you are :)

Once you are in a local repository and want to replicate a local branch on the server, use the following commands:

# If not yet added - add the remote server to your git repository
# `somelabel' is just a throwaway pointer (name) used between the following
# 2 commands
git remote add somelabel https://chromium-review.googlesource.com/${repo-path}
# This is the actual push which will create a branch named <remote-branch-name>
# on the server with the contents of the <local-branch-name> from the local
# repository.
git push somelabel <local-branch-name>:refs/heads/<remote-branch-name>

How do I add my project to the manifest?

IMPORTANT NOTE: Please verify that this repo is public and non-empty before adding it to a manifest.xml file.

  1. Add project to both manifest-internal and manifest.
  2. It is easiest just to clone the repository in a directory.
  3. Please, keep the entries is alphabetical order.
# cd to a directory where you want to checkout the internal manifest
git clone https://chrome-internal.googlesource.com/chromeos/manifest-internal.git
cd manifest-internal/
git checkout -b foo origin/master
vi full.xml  # add your project in alphabetical order
git commit -a
# make sure git thinks your author email is set correctly with an @chromium.org address
git push origin HEAD:refs/for/master  # Creates Gerrit CL (access with google.com account)

# Repeat all the above steps for the public manifest:
#    https://chromium.googlesource.com/chromiumos/manifest
# (access with chromium.org account)

# If your change gets rejected due to need for rebase:
git remote update
git rebase origin/master
# Make sure the rebase does the right thing

# Get the "xx/yyyy" from the gerrit page in the "Download" section
# where it mentions refs like: "refs/changes/xx/yyyy/z"
git push origin HEAD:refs/changes/xx/yyyy

How do I make a copy of an upstream repository on the git server?

  1. Talk to relevant people on IRC or the chromium-os-dev mailing list to make sure it's ok to add the new repositories
  2. Create a new chromium-os repo for your new repository.
  3. Ask chrome-infrastructure team for giving you permission to do perform merges and push branches on this repository.
  4. Initialize the initial set of branches. Example below:
# The upstream git repository is at:
# http://example.com/example.git
# The corresponding chromium os repo is:
# https://chromium.googlesource.com/repo.git

git clone http://example.com/example.git
cd example

# chromiumoslabel is just a pointer to our chromium os repository
# (where you want the upstream repo to be

git remote add chromiumoslabel https://chromium.googlesource.com/repo.git

# Now push a given commit hash from the upstream repo to the chromiumos copy. # Here we are pushing HEAD from the upstream repo as the master
# branch on the chromium os copy. You can also use a specific
# commit hash (man git-push for details).
git push chromiumoslabel HEAD:refs/heads/master

# Now also create a new branch on repo.git which may be used
# to track upstream, pull in new patches, etc.
git push chromiumoslabel HEAD:refs/heads/upstream

# Finally, do not forget to add a README.chromium to the master
# branch (This should be done as a normal Gerrit code review.)
Comments