Skip to content

Instantly share code, notes, and snippets.

@willkg
Last active August 29, 2015 14:01
Show Gist options
  • Save willkg/93cdcbbe7195a0539d4b to your computer and use it in GitHub Desktop.
Save willkg/93cdcbbe7195a0539d4b to your computer and use it in GitHub Desktop.
fab rule for status report
"""
This is the rule in my fabfile.py that generates the bulk of the
status reports I send every two weeks.
"""
from fabric.api import local
REVISION_URL = 'https://input.mozilla.org/media/revision.txt'
PRIMARY_DEVS = [
'(Will Kahn-Greene)'
]
@timeit
def status_report(sha):
"""Generates report of what was done and what's in prod
Execute with 'fab sprint_report:SHA'
"""
def get_log(begin, end):
log = local(
'git log --format="%h %s (%cn)" --reverse {0}..{1}'.format(begin, end),
capture=True)
log = log.splitlines()
for i, line in enumerate(log):
# Weed out primary devs--we only want to call attention
# to contributors.
for dev in PRIMARY_DEVS:
if line.endswith(dev):
log[i] = line.replace(dev, '')
log[i] = '* ' + log[i]
return log
# Figure out the deployed sha
deployed_sha = local(
'curl -XGET "{0}"'.format(REVISION_URL), capture=True)
# Figure out what landed and what got deployed
landed_and_deployed = get_log(sha, deployed_sha)
landed = get_log(deployed_sha, 'HEAD')
head = local('git rev-parse --short HEAD', capture=True)
# Print it all out
print 'Landed and deployed:\n'
for line in landed_and_deployed:
print line
print ''
print 'Landed, but not deployed:\n'
for line in landed:
print line
print ''
# Print out HEAD so it's easy to do the next report
print 'HEAD: {0}'.format(head)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment