Skip to content

Opening a pull request

Ankith edited this page Sep 16, 2024 · 7 revisions

So you want to fix a bug, or add an amazing new feature to pygame and you want to know how to get started?

The answer, is with a pull request.

Pull Request: Step-by-Step

The standard process for opening a pull request is the same across all open source GitHub based projects.

  1. Create a fork of the pygame-ce repository on your own github profile. You do this by clicking the 'Fork' button on the top right hand side of the repository:

    image

  2. Checkout/clone your new fork to your local computer. The GitHub interface gives you a lot of options here:

    image

    Personally I use my preferred IDE PyCharm to Clone from this menu:

    image

    Where I just paste in the URL of the repository.

  3. Create a new branch from the main branch of your forked, cloned local repository where you will make your changes. Try to give it a sensible name that relates to your changes, this will help reviewers later. I personally make branches with PyCharm's interface here:

    image

    Found in the bottom right hand corner of PyCharm's main window. Though there are many tools and ways to make branches.

  4. Time to actually make your changes. This is a whole separate topic but we will assume you have successfully fixed a bug or made that amazing new feature.

  5. Make sure your code actually compiles and does what it is supposed to do with a bit of testing. Better still write some unit/CI tests for the fix or new feature.

  6. Run your changes through the linting and autoformatting programs. That means something like: ruff format test/blit_test.py in the terminal/command line for python code, or clang-format src_c/math.c -i for C code. PyCharm has a terminal built in, but you can also use your normal OS terminal/shell. ruff is easy to install from PyPI using pip, but clang-format may require a bit more effort on some platforms to make it actually work. I personally grab the latest LLVM release (-win64.exe) from this page and install the python package from PyPI.

  • This step can also be performed automatically before a commit by setting up pre-commit and using the hooks provided by pygame-ce. If changes need to be made to be compliant, then the pre-commit hook will make the changes for you and will abort the commit. Re-add the modified files and try your commit again. This tool is installed with pip install pre-commit. To set up the git hooks, run pre-commit install in your pygame-ce source tree.
  1. Commit everything to your local repository with a short sensible one line commit message. This message will eventually be visible in the public github repo so you want it to make some sense.

  2. Push your local repository changes to your personal remote fork.

  3. Finally navigate to the main pygame Community Edition repository online and you should see a yellow box asking if you want to make a pull request from your recently pushed remote branch. Do so and you will finally open a pull request that the community can review and hopefully merge into the main repository. If all goes well your code may be in the next release of Pygame Community Edition!