Skip to content

Contributing to the Code

John Holt edited this page Mar 16, 2018 · 8 revisions

Wiki > Contributing to the Code

The code is shared among all instruments this means that you need to be careful when editing the repository. In general once a feature is released try to only change the interface in a backward compatible way. For example when adding a parameter to a function call add a sensible default which replicates the original behaviour. In general you should not need to change code in instrument folder except for your own instrument. Any other code is potentially shared, try to leave good commit comments to explain what you were doing.

Starting a change

Development should be done on feature branches usually from the latest version of the code. This means several features can be developed independently and only committed at the point that the code is working. The process for doing this is:

  1. Checkout master branch git checkout master
  2. Update to current version git pull
  3. Create a branch git checkout -b "<branch name>"
  4. Push this to the server with git push --set-upstream origin <branch name>

This has created a branch on which to work, this will not effect anyone else but the code can be freely stored and shared with others if required.

Making change

Once you have started a change and are on your feature branch you can now edit the code. Best practice is to make lots of small changes and to commit the changes to the branch as you go. At the end of the commit the code should be runable but may not do everything you want it to. To commit the code:

  1. Find out which files have changed git status
  2. Find out changed git diff (use up and down arrows and q to quit)
  3. Add files you want to include, either:
    1. Add all tracked file git add -u
    2. Add all changed files including untracked files git add -A
    3. Add a specific file git add <full path of the file>
  4. Check what will be committed git status those in green will be committed.
  5. Commit the changes to local repository git commit -m"<message describing commit> (<your name>)"
  6. Push the changes to the central repository git push

Finishing the Changes

Finally you need to put your changes back onto the master branch. The easiest way to do this is to create a pull request.

  1. Go to the code in git hub.
  2. Click "New Pull Request Button"
  3. Select your branch
  4. Add any details and click ok

Ideally you now send the pull request to someone else to review. They should review the changes and if they are happy:

  1. Click "Merge pull request"
  2. Add a comment and then click "Confirm merge"
  3. The click "Delete branch"; this removes the branch as an active branch it can be restored later if needed.
Clone this wiki locally