In this section, we'll address an issue in the PyGMT repository using git and your local development environment.
We'll address issue 1445 in the PyGMT repository while learning how to submit pull requests for changes that you make locally.
-
Navigate to your local cloned copy of the PyGMT repository using
cd
: -
Check the current repository status:
git status
-
Checkout the main branch:
git switch main
-
Pull the latest changes from the remote repository down to your local copy:
git pull
-
Create a new branch (give it a name like add-alias-xxxx) and switch to that branch:
git switch -c add-alias-rose
-
Check the current branch and status:
git status
-
Open the file associated with the function that you were assigned in the
/pygmt/src/
directory. -
Find the
use_alias
decorator in the file immediately above the definition for the function that you were assigned. -
Add the alias(es) in your assigned task to the list of parameters passed to the
use_alias
decorator in the formatshort_form="long_form"
.- Note: For steps 9 and 10, refer to the ISO basic Latin alphabet when ordering the aliases. Basically, sort capital letters ABC...XYZ before small letters abc...xyz.
-
In the docstring of the function, add the alias(es) to the list using the format
{short_form}
.
-
Check the docstring appearance in a Python kernel
- Start a Python kernel (Jupyter notebook or iPython).
- Import pygmt:
import pygmt
. - View the docstring for your assigned method (e.g.,
help(pygmt.Figure.grdimage)
). - Check that the alias is included in the list of aliases and the parameters section.
-
Stage and commit your changes (replace
<your-module>
with the name of the module that you are working on):git add pygmt/src/<your-module>.py git commit -m "Add missing aliases to <your-module>
-
Check the status and log:
git status git log
-
Push your changes to your fork (replace
<your-github-username>
with your GitHub username and<branch-name>
with your branch name.):git push -u <your-github-username> <branch-name>
-
Make a pull request:
- Go to your fork on GitHub, where you should see a button to create a pull request from your branch. Click on the "Compare & pull request" button.
- Check the base repository, base branch, head repository, and compare selections.
- Enter a descriptive pull request title. E.g. "Add missing common options to rose"
- Enter information about the pull request underneath
**Description of proposed changes**
. - Change
Fixes #
toAddresses #1445
. - Click
Create pull request
, or if possible, click on the dropdown button and selectCreate draft pull request
which indicates it as a work in progress.
Now, you're all done! A maintainer will review your pull request, either suggesting changes or accepting the pull request and merging in your contribution!