from subprocess import check_output

from django import template

register = template.Library()


@register.simple_tag
def git_revno():
    return check_output(['git', 'rev-parse', '--verify', 'HEAD']).strip()[-7:]

from subprocess import (
    PIPE,
    Popen,
)

from django import template
from django.conf import settings

register = template.Library()


@register.simple_tag
def git_revno():
    p = Popen(['git', 'rev-parse', '--verify', 'HEAD'], stdout=PIPE,
              cwd=settings.BASE_DIR)
    out, _ = p.communicate()
    return out.strip()[-7:]

Fix git-revno to always run in one dir
Fix git-revno to always run in one dir
