Git for code management

From Nanuna internal
Jump to: navigation, search

NSA CM Reporting Tool Git Setup

The following set-up for managing source code has been used: The developer (Chris) has a git repository on her own development computer. The code in the master branch contains the current deploy-ready version. The code in the TWP branch contains a version that is being developed for general use for other ARM sites (and which requires alterations that are not yet ready for deployment).

The development process is, briefly:

  • For each major feature or feature set or development push, create a new branch.
  • Develop and test in this branch.
  • Deploy code from this branch to staging server and test more.
  • Before production deployment, merge code into master branch.
  • Deploy from master branch.

A remote repository was created on a local server (nanuna) and is accessed via ssh. Right now, it serves primarily as a backup and was created under a personal username. Only the master and TWP branches are currently pushed to the remote repository.

$ git remote -v
origin (fetch)
origin (push)
$ git ls-remote origin
93f42e0877109dee035c1916e8aec5ea74b4ceb2	HEAD
d64c342856959219c6a5f161507f4a8d111b7927	refs/heads/TWP
93f42e0877109dee035c1916e8aec5ea74b4ceb2	refs/heads/master

Git-generated version fingerprints

Git has no provisions to populate "version" variables embedded in the code, as this makes little sense for a distributed version-control system in the general case of large numbers of collaborators constantly exchanging code. However we can (and do) use it to automatically generate a human-readable version "stamp" that is deployed with the Python code.

This is implemented as follows. Via a pre-commit hook, just before a commit takes place, git describe is called and the output written into a file in the root of the Django project directory. As this is a Python file, it is automatically included in each code deployment.

Personal tools