You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 24 Next »

Quick Start (especially for non-committers)

Here is a workflow for non-committers to kick start feature development on GitHub:

  1. Create an account on GitHub.
    See Setting Up Git
  2. Fork the Apache Repo:
    1. Go to https://github.com/apache/cloudstack.
    2. Click Fork.
      See Fork a Repo
  3. Clone your fork:
    git clone https://github.com/<username>/cloudstack.git
  4. Configure remote:
    1. git remote add upstream https://git-wip-us.apache.org/repos/asf/cloudstack.git
      The GitHub repo is a mirror and not the definitive source, so we use https://git-wip-us.apache.org/repos/asf/cloudstack.git and not https://github.com/apache/cloudstack
  5. Sync to upstream periodically (for long running features, read:daily)
    1. git checkout <feature-branch>
      This sets your local working set to the branch you want to pull the latest changes into.
    2. git fetch upstream
    3. git merge upstream/<feature-branch> (or git merge --no-ff to preserve git branching history)
  6. When you have some code to contribute, submit changes to the Review Board
    1. Create an Apache Review Board account at https://reviews.apache.org
    2. Install RBTools
    3. Set the default reviewboard.url, e.g. git config reviewboard.url https://reviews.apache.org
    4. Call post-review
    5. Edit the resulting URL to assign a reviewing group and to describe the change.
      RBTools automates creating a diff file that captures the changes you've made and publishing them to the ReviewBoard site.

Committers will not be looking at your repo by default. Therefore, alert the cloudstack-dev mailing list of your work and periodically request the incremental commits you make be reviewed.

It is also best to work on feature branches rather than working directly on master even in your private fork. When the patch is ready for submission push the squashed patch through reviewboard. If the patch is sizeable and touches many projects in the repo, best to break it down into smaller chunks for easier and quicker review by multiple committers.

Holler for help on the lists if you're stuck and ever need help. 

Using Git in CloudStack

Git Config

# Set the name of the user for all git instances on the system
git config --global user.name "Firstname Lastname"
# Set the email-address of the user for all git instances on the system
git config --global user.email "your_email@youremail.com"

Committer workflow

Your own work can be committed easily - git push is all you need. Be mindful of the branch that you are working in and ensuring that it is the current branch for development. It might also behoove you to make changes to multiple branches (e.g. current development and head). Please be mindful that just because you have commit privileges does not relieve you of the obligation to develop in the open, which means communication on the cloudstack-dev list. 

Handling patches

As a committer one of your responsibilities is to review and commit patches from others. The patches must pass through the bugtracker or the mailing list so they can be tracked.

Patches should be applied via git-am (in other words, don't just use a diff, it records no author information). 

Proposed Gitflow based Check-in Process

Reference thread - http://markmail.org/message/j5z7dxjcqxfkfhpj

  1. git-flow we are going to follow is explained here http://nvie.com/posts/a-successful-git-branching-model/
  2. This is the proposal for first cut
    1. branch ‘develop’ from 'master’
    2. branch ‘release/4.5' from the develop
    3. merge ‘release/4.5' to master once the release voting is done.
  3. This would be the flow for a hot fix
    1. branch off from the release tag on master. in this case it would be release/4.4.0
    2. commit the fixes in hotfix/4.4.1
    3. do the release
    4. merge to develop
    5. merge to master and update tags
    6. delete hot fix branch
  4. for any LTS release create a support branch when required using git-flow support
    1. http://stackoverflow.com/a/16866118/201514

Using the git-flow git extension available at https://github.com/nvie/gitflow can reduce the number of commands/errors

Reviewer guidelines

  1. Every commit should have unit tests
  2. every feature/merge request should have unit and marvin integration tests
  3. A commit should not have check style or find bugs issues
  4. Any coverity issues reported in the new code should be addressed immediately
  5. Developer should run the BVT on the simulator before doing a checkin 
    1. Validating check-ins for your local changes, using Simulator

Non-committer workflow

Cloning

First you need to have a copy of the source - you should be able to acquire that by cloning the repo:

$ git clone https://git-wip-us.apache.org/repos/asf/cloudstack.git

Branch

The CloudStack repo has multiple branches, some version specific, you'll need to figure out which one you need to work with, but we'll make the assumption that master is OK for this purpose. Now, when you are ready to actually hack on CloudStack you should create your own topic branch locally. Lets say you wish to work on a specific bug, then you should work on that bug (and only that bug) in its own local branch (known as a topic branch), and you should use a descriptive name for it.

Suppose you are working on bug CS-15081 - you'd create a branch by the same name: $ git checkout -b CS-15081   (this both creates the branch and switches to using it) 

Now you can make your changes - and once done submit patches. 

Commit Messages

Please make your commit messages descriptive:

  • Commit messages should be clear, concise and provide a reasonable summary to give an indication of what was changed and why.
  • Commit messages should provide enough information to enable a third party to decide if the change is relevant to them and if they need to read the change itself.
  • Avoid committing several unrelated changes in one go. It makes merging difficult, and also makes it harder to determine which change is the culprit if a bug crops up.
  • Avoid committing style or whitespace fixes and functionality fixes in one go. It makes merging difficult, and also makes it harder to understand just what functional changes were made. In the case of documentation files, it can make the job of the translation teams more complicated, as it becomes difficult for them to determine exactly what content changes need to be translated.
  • Avoid committing changes to multiple files in one go with a generic, vague message. Instead, commit each file (or small, related groups of files) with tailored commit messages.

A good commit message should look like this:

Header line: Explain the commit in one line

Body of commit message is a few lines of text, explaining things in more detail,

possibly giving some background about the issue being fixed, etc etc. Use bullets if possible:
 - Line 1
 - Line 2 etc.
 * Start works too, instead of -

The body of the commit message can be several paragraphs, and please do proper word-wrap

and keep columns shorter than about 80 characters or so. That way "git log" will show things

nicely even when it's indented.

Reviewed-by: Individuals who reviewed, or link to review on review.apache.org
Reported-by: whoever-reported-it, if applicable (usually this is recorded in the Jira bug)
Submitted-by: give credit to other individual for any patch submission committed by you
Signed-off-by: Your Name <youremail@yourhost.com>

Note that there exists a git hook to prepare a commit form for you, located at tools/git/prepare-commit-msg. One simply needs to link to it in order to use it:

ln -s ../../tools/git/prepare-commit-msg .git/hooks/prepare-commit-msg

Please use a logical prefix, which should be:

  • CLOUDSTACK-XXX-bug-id prefix: Explain the bugfix in one line; This is for only bug fixes.
  • Maven: If this changes the build system
  • Doc: If this is doc related change
  • awsapi: If the code changes several things inside a subproject, use artifactId sans the cloud- prefix such as: plugin-netapp; this should be lowercase
  • NameOfTheClass: If this patch purely changes to ThisClass, this should be CamelCase

Patches

Patches encapsulated all the changes you want to make to another branch. Patches are used to communicate the changes that you want incorporated into Apache CloudStack.

Creating patches

Patches should be created with git-format-patch - and you should specifically be basing that against the branch you are targeting for inclusion, so for instance using our above example from the CS-15081 branch we'd run:

$ git format-patch -s master

The above would produces a patch file for each commit in the directory (unless you specified one with -o /path/to/patch/folder).
If you've a series of commits that you want to put into a single file, try

$ git format-patch -s master --stdout > ./mycommits.patch

Sending patches

CloudStack currently doesn't utilize Github pull requests.

One alternative is to post the patch on Review Board.

  1. Create an Apache Review Board account at https://reviews.apache.org
  2. Install RBTools
  3. Set the default reviewboard.url, e.g. git config reviewboard.url https://reviews.apache.org
  4. Call post-review
  5. Edit the resulting URL to assign a reviewing group and to describe the change.
    RBTools automates creating a diff file that captures the changes you've made and publishing them to the ReviewBoard site. The drawback is that you loose the meta data associated with each commit that you've made. Howevever, Apach Review Board can't handle a commit that references the same file multiple times.

More materical on submitting a patch to Review Board

FIXME: This needs checking

An alternative to Review Board is to email that patch to the cloudstack-dev mailing list with [PATCH] in the subject line.

You should expect some feedback on your patch within a week. If you don't receive any - please reply to the original message to make sure folks didn't miss it.

Sending patches can be done with the git send-email tool:

$ git send-email your-newly-generated.patch

How to setup git-send-email tool:

  • yum install git-email or sudo apt-get install git-email (this will install git send-email tool)

The below will configure your .gitconfig globally:

  • git config --global sendemail.smtpserver <smtp-server-name>
  • git config --global sendemail.to <emailing-list>
  • git config --global sendemail.from <email-id>

Apply patches

If the patch to be applied gets the commit details in the header, then use

  • git am < <patch> to apply the patch, which will automatically add newly added files to tracked files.
  • git commit -as --author='Foo Bar <foo@bar.com>' for proper commit attribution

If it's just a raw patch, then use

  • git apply <patch>
  • git add <new files>
  • git commit -as --author='Foo Bar <foo@bar.com>' for proper commit attribution

Words of wisdom

Never use the --force

Git assumes that if you have commit privileges that you are to be trusted, and generally this is a good thing. However, occasionally people are lured by the dark side of the force and when something doesn't merge cleanly, or their push doesn't work - they are tempted to whip out the --force and make it work. PLEASE NEVER DO THIS. It's is almost universally wrong. Please tell us about your problem on cloudstack-dev and let us help you fix it. 

Line endings

The coding standard for CloudStack says that unix line endings (LF) are used instead of CRLF (Windows line endings). You should set your editor and git configuration to behave properly. 

For more information: 

http://help.github.com/line-endings/

http://git-scm.com/docs/git-config

Fixing things for folks

In short, please don't. If non-committers have a patch 95% of the way - comment and tell them what is necessary to make the patch acceptable. Let them fix their own patch and resubmit. Yes you can probably fix things more quickly, but it's important for community growth (both in number and experience) that folks do this themselves.

  • No labels