Skip to content

The Contributor's How to Guide

NateStedman edited this page Apr 10, 2011 · 3 revisions

The Contributor's How to Guide

How to make changes

If you are on Windows open up the git bash, everyone else grab a terminal. Remember, commit early and often and always check your work before committing. Check everything again before pushing to github!

  1. Check for changes upstream:

    cd /path/to/Observatory
    git pull origin
    
  2. Make sure you are on the right branch, you probably want the rcos branch:

    git branch
    > * master
    > rcos
    > rcos_production
    git checkout rcos
    
  3. Make whatever changes you want to any files you need to.

  4. Git can tell you what branch you are on and what you have done at any time:

    git status
    
  5. Test out your changes using manage.py:

    cd Observatory/observatory
    python manage.py runserver
    #Check it out in your browser @ localhost:8000
    
  6. Decide if the changes belong on master or rcos:

    master is for generic changes to the system
    rcos is for rcos specific information and changes
    If you don't know what rcos-production is for, don't commit to it
    
  7. Checkout the right branch, add your changes, and commit:

    git checkout rcos
    git add path/to/file1 path/to/file2 path/to/file3
    git status #Review what you are committing
    git commit -m "Your message here. Be descriptive"
    
  8. Check everything again, if you push something broken, its hard to fix

  9. Push your changes up to github:

    git push
    
  10. Check github for your changes!

    http://github.com/NateStedman/Observatory/commits/<branchname>

  11. Repeat as necessary

How to handle pull requests

Github has a pretty nice and simple help page for this if you view the pull request and click the Merge Help button.

In general there are 3 steps

  1. Add a new remote location for their repository:

    git remote add bamnet-observatory https://github.com/bamnet/Observatory.git
    
  2. Grab and review their changes on a new branch:

    git checkout -b bamnet rocs
    git pull bamnet-observatory rcos
    cd observatory
    python manage.py runserver
    
  3. If everything checks out, merge the changes and push:

    git checkout rcos
    git pull bamnet-observatory rcos
    git pull #check for changes in origin
    git push #push the new commits
    

How to push changes to production

All the tasks here could probably be wrapped into shell scripts

Plan A (Everything just works)

  1. Log onto the server (if you have access):

    ssh <user>@rcos.cs.rpi.edu
    > Password: **********
    
  2. Grab the deployment permissions:

    sudo su www-data
    > Password: **********
    
  3. Grab the changes from github:

    cd /var/www/Observatory/
    git fetch origin
    
  4. Make sure you are on rcos-production:

    git branch
    > ...
    > rcos
    > * rcos-production
    > ...
    
  5. Merge the fetched changes into production:

    git merge origin/rcos
    
  6. Restart Apache (only required if Python files changed, but do it anyways):

    sudo /etc/init.d/apache2 restart
    
  1. Make sure that everything worked:

    http://rcos.cs.rpi.edu
    

Plan B (Everything just broke)

  1. Make sure you are in the repo with deployment permissions:

    sudo su www-data
    cd /var/www/Observatory
    
  2. Revert the changes to before the merge:

    git checkout HEAD^
    
  3. Call for help!!