Jump to: navigation, search

Difference between revisions of "Your first patch (Zaqar)"

m (Set your local repository)
(Redirected page to Zaqar/Your first patch)
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=== Learn how we work ===
+
#REDIRECT [[Zaqar/Your_first_patch]]
 
 
* What [[Open]] means to us.
 
* How our [[ReleaseCycle|Release Cycle]] works.
 
* Our [[BranchModel|Branch Model]].
 
* How to work with [[Bugs|Launchpad Bugs]].
 
 
 
=== Set up your contributor account ===
 
 
 
* Learn [[GerritWorkflow|how to work]] with our [http://review.openstack.org/ Gerrit review system]. Some useful tips are [https://www.youtube.com/watch?v=mT2yC6ll5Qk&feature=youtu.be in this video]. The [[Gerrit_Workflow|Gerrit Workflow]] wiki should be your main resource for how to submit a patch.
 
* Before we can accept your patches, you'll have to sign the [[How_To_Contribute#Contributors_License_Agreement|Contributors License Agreement]].
 
 
 
=== Set your local repository ===
 
 
 
Clone Marconi's code
 
 
 
<pre><nowiki>
 
git clone git://git.openstack.org/openstack/marconi.git
 
</nowiki></pre>
 
 
 
To set Marconi up you will need to install some dependencies and do some basic configurations. Check out how to set up a Marconi's basic deployment in [https://github.com/openstack/marconi Marconi's repository in Github].
 
 
 
Testing the features is always a great way to break the ice with the project and it helps to understand the code better.
 
 
 
Before starting to code, you will have to do some configs to connect your local repository with Gerrit.
 
 
 
You may want to ask Git-review to configure your project to know about Gerrit so the Gerrit Change-Id Commit hook gets installed.  To do so:
 
 
 
<pre><nowiki>
 
cd marconi
 
git review -s
 
</nowiki></pre>
 
 
 
Git-review checks that you can log in to Gerrit with your SSH key. It assumes that your Gerrit/Launchpad user name '''is the same''' as the current running user. If that doesn't work, it asks for your Gerrit/Launchpad user name. You can avoid that question by configuring your Gerrit username, as follows:
 
 
 
<pre><nowiki>
 
git config --global gitreview.username yourgerritusername
 
</nowiki></pre>
 
 
 
If you don't remember your Gerrit user name go to the [https://review.openstack.org/#/settings/ settings page on Gerrit] to check it out (it's not your email address).
 
 
 
Note that you can verify the SSH host keys for review.openstack.org here: https://review.openstack.org/#/settings/ssh-keys
 
 
 
If you get the error "We don't know where your Gerrit is", you will need to add a new git remote. The URL should be in the error message. Copy that and create the new remote.
 
 
 
<pre><nowiki>
 
git remote add gerrit ssh://<username>@review.openstack.org:29418/openstack/marconi.git
 
</nowiki></pre>
 
 
 
In the project directory, you have a `.git` hidden directory and a `.gitreview` hidden file. You can see them with:
 
 
 
<pre><nowiki>
 
ls -la
 
</nowiki></pre>
 
 
 
Once you have this done, you can start working on your patch!
 
 
 
=== Hack, hack, hack! ===
 
 
 
==== Pick a bug ====
 
 
 
You can start tacking some bugs from the [https://bugs.launchpad.net/marconi%20 bugs list in Launchpad]. When you find a bug you want to work on, just assign yourself.
 
Make sure to read the bug report and, if you need more information, ask the reporter to provide more details.
 
 
 
If you find a bug that it's not in the [https://bugs.launchpad.net/marconi%20 bugs list in Launchpad] (props for that!), just report it and wait for another developer to confirm it. When it's confirmed, you can start working on it.
 
 
 
To start working on your bug, make sure to follow the [[Gerrit_Workflow#Normal_Workflow|Gerrit Workflow]].
 
 
 
==== Design principles ====
 
 
 
Marconi lives by the following design principles:
 
 
 
# DRY
 
# YAGNI
 
# KISS
 
 
 
 
 
Try to stick to them when working on your patch, the reviewers will appreciate that!
 
 
 
=== Submit your patch ===
 
 
 
Once you finished coding your fix, go ahead and [[Gerrit_Workflow#Committing_Changes|submit it for review]]. Other Marconi devs will try it and make their comments, and when you get two or more +1 and a core reviewer approves it, it will get merged. Well done!
 
 
 
==== Common Problems ====
 
1. You realized that you were working in master and you HAVEN'T made any commits.
 
 
 
Solution
 
<pre>
 
git checkout -b newbranch    #if you already created the branch, omit the -b
 
git commit -a -m "Edited"
 
</pre>
 
Now all your changes are in newbranch. Problem solved!
 
 
 
2. You realized that you were working in master and you HAVE made commits to master
 
 
 
Solution
 
<pre>
 
git branch newbranch
 
git reset --hard HEAD~x    #x is the number of commits you have made to master. YOU WILL LOSE ANY UNCOMMITTED WORK
 
git checkout newbranch
 
</pre>
 
Your commits are now in newbranch. Problem solved!
 
 
 
3. You made multiple commits and realized that Gerrit needs one commit per patch
 
You need to squash your previous commits. Make sure you are in your branch and follow [http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html this] guide.
 
Fill in the commit message as specified on the [https://wiki.openstack.org/wiki/Gerrit_Workflow#Committing_Changes Gerrit Workflow] page
 

Latest revision as of 18:42, 5 December 2014