Skip to content
jccrane edited this page Jan 23, 2020 · 42 revisions

SIVIC Development with GIT.

We are basing our development model on this article: GIT Development Model . The major difference is that we are pushing our features to origin for visibility by other developers.

http://stackoverflow.com/questions/21661263/gitflow-safely-merge-develop-changes-to-a-feature-branch


Creating a feature branch for new development

  1. Clone repo (only do this once the first time). https is recommended, but the ssh version (2nd) is also included here:
    git clone https://github.com/SIVICLab/sivic.git
    git clone git@github.com:SIVICLab/sivic.git

  2. Checkout develop branch:
    git checkout develop

  3. Create a new feature branch, by convention feature/feature_name, that is based on the remote "origin/develop" branch (this new branch will track origin/develop):
    git checkout -b feature/feature_name origin/develop

  4. Push the new branch to the remote:
    git push -u origin feature/feature_name


Develop and stage your work in your local branch, push your feature changes to remote:

git status
git add <some-file>
git commit
git push


Keeping your feature branch up to date with most recent commits in develop branch

"To integrate one branch into another you have to either merge or rebase. Since it's only safe to rebase commits that aren't referenced anywhere else (not merged to other local branches; not pushed to any remote), it's generally better to merge."[ref]

  1. Switch to the develop branch and pull down the most recent commits from the remote repo:
    git checkout develop
    git pull

  2. Switch back to your feature branch:
    git checkout feature/feature_name

  3. Now merge origin/develop into your current checked out feature branch (feature/feature_name):
    git merge origin/develop

  4. Push your merged feature branch to the remote:
    git push

  5. If your feature is ready to merge into the remote develop branch:

  • add any test cases if you haven't already done so (test driven dev!), see below
  • run the test suite, see below
  • submit a PR, see below

###Create a Pull Request(PR) to merge your feature branch into remote develop

Prerequisites:

  • Your feature branch should be up to date with the most recent develop commit (see above notes under "Keeping your feature branch up to date with most recent commits in develop branch")
  • You should have run the SIVIC test suite (link to instructions)
  1. Create New SIVIC PR
  2. Set "base:" dropdown to "develop"
  3. Set "compare:" dropdown to the feature you want to merge into develop
  4. add "needs review" tag
  5. add the revision number tag under milestones
  6. Document your feature including any API changes, state that the test suite passed and if you needed to add new test cases.

Useful commands:

  1. Check to see the current branches and:
    git branch -a
  2. Diff current branch vs remote, examples (list file diffs, or only file names, or the diffs from a specific file):
    git diff feature/feature_name origin/develop
    git diff feature/feature_name origin/develop --name-only
    git diff feature/idf_image_loading origin/develop libs/src/svkDcmHeader.h
  3. configure to only push/pull current branch:
    git config push.default simple

###Building the package for development and debugging:

To configure and build for debugging out-of-source:

  1. Make a sub-dir for the out-of-source debugging build. For example: mkdir working/debug

  2. cd into this directory and configure
    cd working/debug

    make -f ../../Makefile.ctest configure_debug

  3. build the entire project, e.g.:
    make -j4


###Testing:
This describes how to run the CTest suite for the SIVIC project.

  1. Checkout test cases from UCSF Radiology SVN repo (URL: https://intrarad.ucsf.edu/svn/rad_software/surbeck/brain/sivic/trunk/test_data) into the root of your git clone:
    cd sivic
    svn co https://intrarad.ucsf.edu/svn/rad_software/surbeck/brain/sivic/trunk/test_data test_data

  2. Make a sub-dir for out-of-source build/test. For example: mkdir working/testing
    cd working/testing

  3. Run the "experimental_fast" target in the top level Makefile (Makefile.ctest):
    make -f ../../Makefile.ctest experimental_fast

  4. If a particular test fails you can rerun it and look at the diffs. For example if the test named "11XPF_2_DDF" fails and you want to rerun that single test:
    ctest -R 11XPF_2_DDF --verbose