Skip to content

Instantly share code, notes, and snippets.

@gmarceau
Last active February 15, 2017 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmarceau/43ac17046c828939c0d6033bb3b82b57 to your computer and use it in GitHub Desktop.
Save gmarceau/43ac17046c828939c0d6033bb3b82b57 to your computer and use it in GitHub Desktop.
Send the output of a command to an Airtable table, along with timestamp and summary of the current git state
#!/usr/bin/env python
import sys
from airtable import airtable
import datetime
from plumbum.cmd import git
_, api_key, base_id, table_name = sys.argv[0:4]
all_stdin = sys.stdin.read()
branch = git('rev-parse', '--abbrev-ref', 'HEAD').strip()
commit = git('rev-parse', '--short', 'HEAD').strip()
diffs = git('diff', '--shortstat')
git_status = '{} {} {}'.format(branch, commit, diffs)
at = airtable.Airtable(base_id, api_key)
fields = {
'Date Time': str(datetime.datetime.now()),
'Commit': git_status,
'Output': all_stdin
}
at.create(table_name, fields)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment