Auto-tools/Projects/Mozmill/RepoSetup: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
 
(48 intermediate revisions by 7 users not shown)
Line 1: Line 1:
= Getting Started =
= Getting Started =
* Get a github account
* Get a [https://github.com/ GitHub account]
* Fork the mozautomation/mozmill repo (use the github UI for this)
* Fork the [http://github.com/mozilla/mozmill mozilla/mozmill] repo (use the Github UI for this)
* Install git on your system
* Install [http://git-scm.com/ git] on your system
* Clone your fork using your ssh key URL on github:  
* Clone your fork using your ssh key URL on Github:  
<pre>git clone git@github.com:<github username>/mozmill.git</pre>
<pre>git clone git@github.com:<your-github-username>/mozmill.git</pre>
* If you don't want to get a Github account, you can still clone the repository, but you won't be able to push upstream or issue pull requests:
<pre>git clone http://github.com/mozilla/mozmill.git</pre>


= Setting up for Development (for 1.4.2)=
= Setting up for Development on Master =
For work on a maintenance release of mozmill, we'll use the maintenance release branch.  Work for the next major version of Mozmill will be done against the "master" branch, which is already set upHere's how to set up the maintenance branch on your system.
Master is where the next version of Mozmill comes fromTo get ready to work here, you'll need to be able to pull in changes from the remote mozautomation repo.  To set that up, you add it as a remote repo:
* Add the mozautomation repo as a remote:  
<pre>cd mozmill; git remote add mozilla git://github.com/mozilla/mozmill.git</pre>
<pre>git remote add mozauto git@github.com:mozautomation/mozmill.git</pre>
* Pull the 1.4.2 code into a local branch:
<pre>git checkout -b mozauto/1.4.2</pre>
* Now you're on a local branch called "1.4.2" with the 1.4.2 code.  Use git checkout to switch between local branches.


= Getting some stuff Done=
If you are going to commit to master:
Let's say we're implementing a bug fix for 1.4.2, here are the steps you'll take:
<pre>git remote add mozilla git@github.com:mozilla/mozmill.git</pre>
* Make sure you're on your local 1.4.2 branch:
<pre>git checkout 1.4.2</pre>
* Create another local branch off of your 1.4.2 branch to do your work in:
<pre>git checkout -b mynewfeature</pre>
* Do your fix, then when you're ready submit the feature for review - push to your branch to your own repo:
<pre>git push origin mynewfeature</pre>
* If the feature is small:
** Send a pull request with github UI
** Take your commit URL (from the github UI) and put that in a comment in bugzilla on the bug you're working on.
* If the feature is large - major refactoring, changes several files etc then make a patch.  You specify which other branch your diffing from.  So if we want to make a patch on our branch for the changes that we've made against the 1.4.2 branch then we do:
** git format-patch mozauto/1.4.2 -U8 --stdout > mypatch.diff
** This gives you a file mypatch.diff which you can now attach to a bug and ask for review.


= For those with commit access =
Here's how to stay up to date with the remote mozautomation repository:
With great power comes great responsibility...
<pre>
* Apply the change you want to checkin
git pull --rebase mozilla master  # Pulls changes from mozilla to your local machine
** For pull requests: make a new local branch with <tt>git checkout -b newfeature </tt>and <pre>git pull ctalbert newfeature</pre>
git push origin master            # Pushes any changes from mozilla to your Github fork
** For patches: make a new local branch and <pre>git apply --stat mypatch.diff</pre>
</pre>
** This will create a branch with the new code
Now you're in sync. Unless you're working on a maintenance release, skip down to "getting stuff done".
** Run the tests (if you're paranoid and/or if the committer didn't)
 
* Push the code up to mozautomation:
= Setting up for Development on 1.5 =
** Merge to your 1.4.2 branch:
For work on a maintenance release of Mozmill, we'll use the maintenance release branch.  Work for the next major version of Mozmill will be done against the "master" branch, which is already set up.  Here's how to set up the maintenance branch on your system (Assuming you've already added mozautomation as a remote repository).
*** git checkout 1.4.2
Pull the 1.5 code into a local branch:
*** git fetch
<pre>
*** git merge <theotherbranch>
git fetch mozilla
*** git push mozauto 1.4.2
git branch hotfix-1.5 mozilla/hotfix-1.5
git checkout hotfix-1.5
</pre>
Now you're on a local branch called "hotfix-1.5" with the 1.5 code.  Use <tt>git checkout</tt> to switch between local branches.
 
To keep your hotfix-1.5 branch updated with the changes to mozauto's 1.5 branch:
<pre>git pull --rebase mozilla hotfix-1.5</pre>
 
= Getting Stuff Done =
If you're doing a fix to the maintenance branch then check out that branch (e.g. hotfix-1.5.1). If you're doing a fix to master then checkout master. Create a new, temporary branch off of that branch to do your work in (with the example of master):
<pre>
git checkout master              // we're doing a fix that will land on mozauto master
git pull --rebase mozauto master  // make sure local master is up to date
git checkout -b myfeature        // create new feature branch based on master
// make some changes to some files
git commit -a -m "did some stuff" // commit changes to your local myfeature branch
</pre>
 
This is important because it keeps your "master" branch clean.  If you use master '''ONLY''' as a area for merging upstream to your fork and mozauto, you'll keep things simple and you will have very few (if any) merge conflicts.  So, that's why we recommend doing all feature/bugfix work in a branch.  You can optionally push that branch up to your github fork as well (that's recommended, then your code doesn't just live on your own machine).
 
== Push a Feature branch to Github ==
If you want give people a link to your new feature or show someone your code, you can push your local changes to your remote fork on Github so that it appears in that UI:
<pre>
git checkout myfeature        // switch to feature branch if not already on it
git push origin myfeature    // pushes feature branch to your remote (fork on github)
</pre>
 
== Ready for a review ==
We want to diff your feature branch against the master branch.  So ensure your master is up to date and create the diff:
<pre>
git checkout myfeature  // switch to myfeature branch if not already on it
git rebase -i master    // Rewrite commits to a single one
git format-patch HEAD^  // Create the patch
</pre>
Now, attach the created file to a bug in [http://bugzilla.mozilla.org Bugzilla] for review.  Don't forget to set the "Review" flag to "?" and add one of the Mozmill module owners in the text box to the right. When in doubt, put in :ctalbert.
 
== Ready to Push ==
''This only applies if you have commit access to mozautomation''
 
Once you have gotten review, it's time to get things ready to land.  First, you may have many commits in your patch.  We really encourage you to [http://www.gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html] to just the salient commits.  You can do that using interactive rebase:
<pre>
git checkout myfeature
git rebase -i master
</pre>
 
Ok, you've gotten your review, your commits are in good shape, and your commit message is correct, then you're ready to push, let's say you want to push to mozilla/master:
<pre>
git checkout master              // Switch to master branch
git pull --rebase mozilla master // Ensure your master is up to date: see below...
git merge myfeature              // Merges your commits to the master
git push origin master          // Pushes to your fork
git push mozilla master          // Pushes to mozilla master
                                // PARTY!
</pre>
You only need to do pull --rebase if your main master branch is NOT clean.  If you have changes on master then this will ensure those changes are applied properly with changes coming downstream from the mozauto master.  If the master branch is clean, doing pull --rebase doesn't hurt anything, so it's the recommended step.
 
== Delete a Feature Branch ==
Once you've checked something in, you probably don't want that feature branch cluttering things up on github. There are two ways to delete a branch. If the branch exists locally, you use one way, if the branch was pushed to your github fork, you use another.  Here they are:
 
To delete a local branch, you must switch to the main branch that the local branch was created from. If the branch was created for a feature on the master, then switch to master. If the branch was created for a feature on a maintenance branch, switch to that maintenance branch.  Failure to do this will give you a "branch is unmerged warning":
<pre>
git checkout master            // Move to some other branch
git branch -D myfeature        // Delete the myfeature branch
</pre>
 
Now, if the branch was pushed to your Github repo, we add another step.
<pre>
git push origin :myfeature    // Removes the branch from github
</pre>
 
= Writing a Test =
This is about writing tests for the Mozmill tool itself, not writing Mozmill tests.  For writing Mozmill tests, please refer to the [https://developer.mozilla.org/en/Mozmill Mozilla Developer Network pages].
 
A test framework for the Mozmill tool itself has been constructed. See: https://github.com/mozilla/mozmill/tree/master/mutt

Latest revision as of 21:30, 4 June 2013

Getting Started

git clone git@github.com:<your-github-username>/mozmill.git
  • If you don't want to get a Github account, you can still clone the repository, but you won't be able to push upstream or issue pull requests:
git clone http://github.com/mozilla/mozmill.git

Setting up for Development on Master

Master is where the next version of Mozmill comes from. To get ready to work here, you'll need to be able to pull in changes from the remote mozautomation repo. To set that up, you add it as a remote repo:

cd mozmill; git remote add mozilla git://github.com/mozilla/mozmill.git

If you are going to commit to master:

git remote add mozilla git@github.com:mozilla/mozmill.git

Here's how to stay up to date with the remote mozautomation repository:

git pull --rebase mozilla master   # Pulls changes from mozilla to your local machine
git push origin master             # Pushes any changes from mozilla to your Github fork

Now you're in sync. Unless you're working on a maintenance release, skip down to "getting stuff done".

Setting up for Development on 1.5

For work on a maintenance release of Mozmill, we'll use the maintenance release branch. Work for the next major version of Mozmill will be done against the "master" branch, which is already set up. Here's how to set up the maintenance branch on your system (Assuming you've already added mozautomation as a remote repository). Pull the 1.5 code into a local branch:

git fetch mozilla
git branch hotfix-1.5 mozilla/hotfix-1.5
git checkout hotfix-1.5

Now you're on a local branch called "hotfix-1.5" with the 1.5 code. Use git checkout to switch between local branches.

To keep your hotfix-1.5 branch updated with the changes to mozauto's 1.5 branch:

git pull --rebase mozilla hotfix-1.5

Getting Stuff Done

If you're doing a fix to the maintenance branch then check out that branch (e.g. hotfix-1.5.1). If you're doing a fix to master then checkout master. Create a new, temporary branch off of that branch to do your work in (with the example of master):

git checkout master               // we're doing a fix that will land on mozauto master
git pull --rebase mozauto master  // make sure local master is up to date
git checkout -b myfeature         // create new feature branch based on master
// make some changes to some files
git commit -a -m "did some stuff" // commit changes to your local myfeature branch

This is important because it keeps your "master" branch clean. If you use master ONLY as a area for merging upstream to your fork and mozauto, you'll keep things simple and you will have very few (if any) merge conflicts. So, that's why we recommend doing all feature/bugfix work in a branch. You can optionally push that branch up to your github fork as well (that's recommended, then your code doesn't just live on your own machine).

Push a Feature branch to Github

If you want give people a link to your new feature or show someone your code, you can push your local changes to your remote fork on Github so that it appears in that UI:

git checkout myfeature        // switch to feature branch if not already on it
git push origin myfeature     // pushes feature branch to your remote (fork on github)

Ready for a review

We want to diff your feature branch against the master branch. So ensure your master is up to date and create the diff:

git checkout myfeature   // switch to myfeature branch if not already on it
git rebase -i master     // Rewrite commits to a single one
git format-patch HEAD^   // Create the patch

Now, attach the created file to a bug in Bugzilla for review. Don't forget to set the "Review" flag to "?" and add one of the Mozmill module owners in the text box to the right. When in doubt, put in :ctalbert.

Ready to Push

This only applies if you have commit access to mozautomation

Once you have gotten review, it's time to get things ready to land. First, you may have many commits in your patch. We really encourage you to [1] to just the salient commits. You can do that using interactive rebase:

git checkout myfeature
git rebase -i master

Ok, you've gotten your review, your commits are in good shape, and your commit message is correct, then you're ready to push, let's say you want to push to mozilla/master:

git checkout master              // Switch to master branch
git pull --rebase mozilla master // Ensure your master is up to date: see below...
git merge myfeature              // Merges your commits to the master
git push origin master           // Pushes to your fork
git push mozilla master          // Pushes to mozilla master
                                 // PARTY!

You only need to do pull --rebase if your main master branch is NOT clean. If you have changes on master then this will ensure those changes are applied properly with changes coming downstream from the mozauto master. If the master branch is clean, doing pull --rebase doesn't hurt anything, so it's the recommended step.

Delete a Feature Branch

Once you've checked something in, you probably don't want that feature branch cluttering things up on github. There are two ways to delete a branch. If the branch exists locally, you use one way, if the branch was pushed to your github fork, you use another. Here they are:

To delete a local branch, you must switch to the main branch that the local branch was created from. If the branch was created for a feature on the master, then switch to master. If the branch was created for a feature on a maintenance branch, switch to that maintenance branch. Failure to do this will give you a "branch is unmerged warning":

git checkout master            // Move to some other branch
git branch -D myfeature        // Delete the myfeature branch

Now, if the branch was pushed to your Github repo, we add another step.

git push origin :myfeature     // Removes the branch from github

Writing a Test

This is about writing tests for the Mozmill tool itself, not writing Mozmill tests. For writing Mozmill tests, please refer to the Mozilla Developer Network pages.

A test framework for the Mozmill tool itself has been constructed. See: https://github.com/mozilla/mozmill/tree/master/mutt