From 0fd11653b1cc821eb5c0d6e5c9bcb994a188d9b6 Mon Sep 17 00:00:00 2001 From: Richard Crowley Date: Wed, 22 Feb 2012 12:31:26 +0000 Subject: [PATCH] Fix #118. --- bin/blueprint-create | 9 +++++++++ blueprint/git.py | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/bin/blueprint-create b/bin/blueprint-create index a55a40e..39894e3 100755 --- a/bin/blueprint-create +++ b/bin/blueprint-create @@ -7,6 +7,7 @@ import sys import blueprint.cli from blueprint import context_managers +import blueprint.git parser = optparse.OptionParser('Usage: %prog [-d ] [-P|-C|-S|...] ' '[-m ] [-r] [-q] ') @@ -57,6 +58,14 @@ if 1 != len(args): parser.print_usage() sys.exit(1) +if not blueprint.git.configured(): + logging.error('please give Git your name and email address so commits have an author') + logging.error('') + logging.error(' git config --global user.email "you@example.com"') + logging.error(' git config --global user.name "Your Name"') + logging.error('') + sys.exit(1) + b = blueprint.cli.create(options, args) try: diff --git a/blueprint/git.py b/blueprint/git.py index a470a13..e330760 100644 --- a/blueprint/git.py +++ b/blueprint/git.py @@ -180,3 +180,12 @@ def commit_tree(tree, message='', parent=None): if 0 != status: return None return stdout.rstrip() + + +def configured(): + """ + Return `True` if the author is configured in Git. This allows Blueprint + to bail out early for users that don't have things configured just right. + """ + return not git('config', 'user.name', raise_exc=False)[0] \ + and not git('config', 'user.email', raise_exc=False)[0]