-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Code review workflow with GitHub and Gerrit
There are several ways to contribute code in GitHub, for example
- forking and creating pull request from a forked repo (https://help.github.com/articles/fork-a-repo)
- branching within the main repo, and doing pull requests from one branch to another.
- working on a local branch, creating a code review using Gerrit, push directly into master (this article).
Tip: if you want to get automatic backups of an NFS directory, but take advantage of fast git performance on a local directory, you can use the instructions above in an NFS directory and use a mirror in a local directory with git-new-workdir.
Then work from the local directory. Files uncommitted are not backed up, but every commit you make is automatically backed up. The script 'git-new-workdir' is described in more detail here: http://nuclearsquid.com/writings/git-new-workdir/.
There is a codereview.settings
file in the repo to configure things automatically, but it never hurts to check:
> cat codereview.settings
# This file is used by gcl to get repository specific information.
GERRIT_HOST: True
CODE_REVIEW_SERVER: https://dart-review.googlesource.com
VIEW_VC: https://dart.googlesource.com/sdk/+
CC_LIST: [email protected]
Pick a branch name not existing locally nor in the remote repo, we recommend that you use your user name as a prefix to make things simpler.
> cd sdk # the repo created above
> git checkout -b uname_example # new branch
> echo "file contents" > awesome_example.txt
> git add awesome_example.txt
> git commit -a -m "An awesome commit, for an awesome example."
> git cl upload origin/master
> git cl web
Then click on the Start Review
button to send email to the reviewers from the Gerrit website.
> echo "better file contents" > awesome_example.txt
> git commit -a -m "An awesomer commit"
> git cl upload origin/master
If new changes have been made to the repo, you need sync up to the new changes before submitting your code. You can do this in two ways:
There are two ways to sync up:
-
merging
> git pull origin master > git cl upload origin/master
-
rebasing
> git pull --rebase origin master (which is similar to first pull and merge in master, and then rebase: > git checkout master > git pull > git rebase master uname_example) > git cl upload origin/master
> git cl land origin/master
This command will close the issue in Gerrit and submit your code directly on master.
After submitting, you can delete your local branch so that the repo is clean and tidy :)
> git checkout master
> git branch -D uname_example # delete local branch
Important
The wiki has moved to https://github.com/dart-lang/sdk/tree/main/docs; please don't edit the pages here.