-
Notifications
You must be signed in to change notification settings - Fork 43
git & GitHub workflow for contributing
The best method for contributing software to the jwql
project is a workflow that involves forking the jwql
repository, developing changes on "feature" branches, and opening pull requests through GitHub.
Note that the jwql
team employs a release-driven git
workflow, as shown in the following diagram:
As such, all feature branches should be branched off of and merged back into the develop
branch.
The first question you will have to figure out is whether you should open an issue for this update - if you think that this change will be solving a significant problem or add a significant enhancement to the project then it would be advantageous to open an issue ticket here. This will allow both individuals and the team as a whole to keep track of the project and our progress as we go. Any appropriate individuals should be assigned to the issue, and a label(s) should be tagged.
Following that, any changes that you want to eventually make to the main
or develop
branch should be done through the workflow where you create a fork and work on your own branch before submitting those changes to be reviewed through a pull request. Instructions on how to do those things can be found below. Note that these instructions are for interacting with git through the command line, however, there are alternatives with graphical user interfaces such as sourcetree.
-
Create a personal fork of the
jwql
repository by visiting thespacetelescope
repository and clicking theFork
button. Note that this only has to be done once. -
Make a local copy of your personal fork by cloning the repository, using the URL found by clicking the green "clone or download" button. Either use HTTP or SSH with one of the following commands:
- with HTTP:
git clone https://github.com/<username>/jwql.git
- with SSH:
git clone [email protected]:<username>/jwql.git
Note that, unless you explicitly delete your clone of the fork, this only has to be done once.
- with HTTP:
-
Ensure that the personal fork is pointing to the
upstream
spacetelescope/jwql
repository:- with HTTP:
git remote add upstream https://github.com/spacetelescope/jwql.git
- with SSH:
git remote add upstream [email protected]:spacetelescope/jwql.git
Note that this only has to be done once.
- with HTTP:
-
Create a "feature" branch off of the
develop
branch on the cloned personal fork to develop software changes on. Branch names should be short but descriptive (e.g.new-database-table
orfix-dark-monitor
) and not too generic (e.g.bug-fix
,updates
). Also consistent use of hyphens is encouraged.-
git branch <branchname>
- you only need to do this when you first create your branch. -
git checkout <branchname>
- you can use this command to switch back and forth between existing branches. - Perform local software changes using the nominal
git add
/git commit -m
cycle.-
git status
- allows you to see which files have changed. git add <new or changed files you want to commit>
git commit -m 'Explanation of changes you've done with these files'
-
⚠️ ⚠️ ⚠️ Please do not develop software changes on your fork's
develop
branch. Be sure to follow step 4 to create a new "feature" branch, so that you can pull updates fromspacetelescope/develop
into your ownorigin/develop
without messing up your feature branch changes.⚠️ ⚠️ ⚠️ -
-
Push the feature branch to the GitHub repository for the personal fork - this will deliver all committed changes to the branch version on the web which makes it accessible to other team members. The following are the commands to do this:
-
git push origin <branchname>
for your first push, or -
git push <branchname>
will also work after the first push of your branch.
-
-
On the
spacetelescope
jwql
GitHub repository, create a pull request - there is a button for that on the previous linked page. You will want to set the base fork pointing tospacetelescope:develop
and thehead
fork pointing to the branch on your personal fork (i.e.username:branchname
). Note that if the branch is still under heavy development, you can putWIP:
at the beginning of the pull request title to signify that the pull request is still a work in progress (i.e.WIP: Example Pull Request Title
). Not until theWIP:
tag is explicitly removed will the pull request be deemed 'mergable'. Be sure to follow the JWQL checklist for contributors of pull requests. -
Assign the pull request a reviewer, selecting one or several member of the
jwql
team (preferably at least @bourque or @laurenmarietta). They will review your pull request and either accept the request and merge, or ask for additional changes. -
Iterate with your reviewer(s) on additional changes if necessary. This will involve addressing any comments on your pull request which can be found on this webpage. You may end up iterating over steps 4.ii, 4.iii and 5.ii several times while working with your reviewer - do not despair.
-
Once the pull request has been accepted and merged, you can delete your local branch with
git branch -d <branchname>
.
As shown in the diagram above, sometimes hotfixes need to be made directly to main
. The nominal workflow for such a scenario is as follows:
-
Assuming steps (1) through (3) in the previous section are completed, create a new branch named
hotfix-<description>
off ofmain
, and commit any necessary changes following the workflow described in step (4) in the previous section. -
Push the hotfix branch to your personal fork, and open two pull requests for that branch: one that merges the branch into
spacetelescope:main
and one that merges the branch intospacetelescope:develop
. -
For each of these pull requests, proceed with the nominal review & merge process as described in steps (7) through (9) in the previous section.
If you wish to, you can keep a personal fork up-to-date with the spacetelescope/jwql
fork by fetching and rebasing with the upstream
remote:
git checkout develop
git fetch upstream develop
git rebase upstream/develop
Users can contribute to another user's personal fork by adding a remote
that points to their fork and using the nominal forking workflow, e.g.:
git remote add <username> <remote URL>
git fetch <username>
git checkout -b <branchname> <username>/<branchname>
- Make some changes (i.e.
add/commit
cycle) git push <username> <branchname>