Submit a patch

From VyOS Wiki
Revision as of 21:56, 26 June 2019 by Runborg (talk | contribs) (Added migrated note)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Warning sign.png This page is migrated to Readthedocs .
Information found on this page is migrated to readthedocs and information found here could be outdated or misleading. https://vyos.readthedocs.io/en/latest/contributing/development.html#submit-a-patch


Patches are always welcome.

You should follow some procedures and guidelines though.

Before you make a patch

In a big system, such as VyOS, that is comprised of multiple components, it's impossible to keep track of all the changes and bugs/feature requests in one's head. We use a bugtracker[1] for it ("issue tracker" would be a better term, but this one stuck).

This information is used in two ways:

  • Keep track of the progress (what we've already done in this branch and what we still need to do).
  • Prepare release notes.

To make this approach work, every change must be associated with a bug number and componant. If there is no bug/enhancement request for the changes you are going to make, you must create a bugtracker[2] entry first. Once there is a bugtracker[3] entry about it, you should reference in your commit message, as in:

[vyos build] T1327: add serial console (115200,8n1) to ISO kernel command-line

[vyos config] T1397: Rewrite the config merge script


If there is no reference to an item in our bugtracker[4] the pull request will be rejected.

Patch limits:

  • If there is a bug that has multiple tasks than it is ok to reference multiple items in a commit and pull request.
  • Multiple bugs can not be fixed in one patch if they have no reference to each other.
  • We only accept bugfixes in packages other than vyos-1x.
  • No new functionality should use old style templates and perl/shell code, use python.

How to make a patch

We only accept patches in git format, because traditional UNIX patch is only good if the code it's going to be applied to doesn't change. If the code changes, merge will fail and the patch will need manual editing, even if there are no real conflicting changes.

Git keeps more information and uses more sophisticated merge algorithms, which makes a fake conflict a rare occurrence. For the same reason you should always make a patch against the latest current branch.

You can make a pull request on https://github.com/vyos.


Find the package

Suppose you want to make a change in the webproxy script.

You can find its package with "dpkg -S":

# dpkg -S /opt/vyatta/sbin/vyatta-update-webproxy.pl 
vyatta-webproxy: /opt/vyatta/sbin/vyatta-update-webproxy.pl

This means it's in vyatta-webproxy submodule, that is, [5].

Make a patch using a fork

Fork the repository in github and make a clone.

git clone https://github.com/<user>/vyatta-webproxy.git

Set your name and email in the git config:

git config user.name "J. Random Hacker"
git config user.email "jrhacker@example.net"

Make your changes and save them. Then do the following for all changes files:

git add myfile

# Or, for a whole dir:
git add somedir/*

Commit the changes:

git commit

Please use meaningful commit descriptions and don't forget to reference the bug number there! Now submit the patch, push and make a pull request.

Make a patch to mail or attach to an item

clone the repository.

git clone https://github.com/vyos/vyatta-webproxy.git

Set your name and email in the git config:

git config user.name "J. Random Hacker"
git config user.email "jrhacker@example.net"

Make your changes and save them. Then do the following for all changes files:

git add myfile

# Or, for a whole dir:
git add somedir/*

Commit the changes:

git commit

Please use meaningful commit descriptions and don't forget to reference the bug number there! Export the patch and send it to maintainers@vyos.net or attach to the bug.

git format-patch

# Or, for multiple commits, suppose you made two:
git format-patch -2

Make a patch using a feature branch (maintainers only)

checkout the current branch and make sure it is up to date.

git clone https://github.com/vyos/vyatta-webproxy.git
git checkout current
git pull origin current

Set your name and email in the git config:

git config user.name "J. Random Hacker"
git config user.email "jrhacker@example.net"

Create the feature branch:

git checkout -b <feature branch name>

Make your changes and save them. Then do the following for all changes files:

git add myfile

# Or, for a whole dir:
git add somedir/*

Commit the changes:

git commit

Please use meaningful commit descriptions and don't forget to reference the bug number there!

Rebase on the current repo if needed and push your branch

git checkout current
git pull origin current
git checkout <feature branch name>
git rebase current
git push -u origin <feature branch name>

Now you create a pull request.