def get_rev(tag=True):
    """Get build revision.

    @param tag  Use git tag instead of hash?
    """
    rev_cmd = "git describe --always --tag" if tag in (True, "True") else \
              "git rev-parse HEAD"
    return local(rev_cmd, capture=True).strip()
Get build revision.

    @param tag  Use git tag instead of hash?