How do I submit a patch to a Launchpad project?

Is it a Launchpad project?

(If you already know that it is a Launchpad project, you can skip this.)

Not all projects found on Launchpad are actually hosted and developed there - some are mirrors of code hosted elsewhere (GitHub/Gitorious/etc), others come from Debian. These original sources are known as "upstream" projects, and it is usually best to submit patches at the source and let the changes arrive "downstream" in Ubuntu (usually in the next release).

It should be clearly indicated on the project page whether it is hosted elsewhere or on Launchpad. If not, just ask the project maintainers how they wish to receive changes. Some upstream projects prefer simple patch files, others prefer submissions/pushes via their respective hosts.

As a special note, official Ubuntu packages (software stored in the official Ubuntu repositories that you can install from the Software Center) have a few different ways to submit patches, as many of those packages come directly from Debian, and should ideally be fixed there rather than only in Ubuntu. (This is a whole other question.)

How to submit a patch

The general way to submit a patch is that you make your branch, commit to it locally and push it back to Launchpad:

bzr push lp:~user/project/branch-name

You can then propose your branch to merge into the parent you branched from, either via the web site, or using the bzr lp-propose command.

If you've filed a bug, and your branch does fix it, be sure to do the following when committing, where 000000 is replaced with your bug number, assuming it is a bug reported on Launchpad, and not elsewhere instead.

bzr commit --fixes=lp:000000

A note on "default" workflow

This is pretty much the typical modern workflow, that you may compare to GitHub. Launchpad has been around a bit longer though, so this workflow evolved after the fact, rather than being built into the system from the beginning, so some older projects may rely on other methods of accepting patches. Most all newer projects rely on this workflow though, where on GitHub the "pull requests" have always been there, and people just default to using it because there was never a means to do something different on GitHub.


Intitial answer based on dobey's answer here and Jorge Castro's answer to a project-specific question. Edits/corrections/suggestions welcome.

  1. Create a Launchpad account. This will include a Launchpad username (LP-USER)

  2. Add your SSH key to launchpad at https://launchpad.net/~LP-USER/+editsshkeys

  3. On Launchpad, note the project name (PROJECT-NAME).

  4. Report the issue against the project. The issue will be assigned a bug number (000000).

  5. Make sure Bazaar is installed dpkg-query -l bzr. You may want to read up on Bazaar/Launchpad integration.

  6. Configure bzr with bzr whoami "Your Name <[email protected]>" and bzr launchpad-login LP-USER

  7. On your machine, check out a local branch of the project

    bzr branch lp:PROJECT-NAME
    

    (This will create a folder called PROJECT-NAME containing the latest project code.)

  8. Get the project running. Make changes. Test your changes. (These steps are project- and issue-specific.)

  9. Commit your changes, including the bug number (000000).

    bzr commit --fixes=lp:000000
    
  10. That will open a commit dialog where you can add a changelog entry explaining your changes.

  11. Push your changes to Launchpad. (This will create a new remote branch associated with your account.)

    bzr push lp:~LP-USER/PROJECT-NAME/NEW-BRANCH-NAME
    

    (NEW-BRANCH-NAME should be a short descriptive name of the issue fixed / feature added)

  12. Open branch in your browser with bzr lp-open or by going to https://code.launchpad.net/~LP-USER/PROJECT-NAME/NEW-BRANCH-NAME/

  13. Propose a merge with bzr lp-propose or from the URL in the last step by selecting "Propose for merging", adding a description, paste in lp:PROJECT-NAME for the branch you want to propose into and click Submit.