diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-11-11 18:01:47 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2013-11-22 13:49:26 +0000 |
commit | 77d75eb06fa07c64b7e14c376fb6e3742ef33fb3 (patch) | |
tree | 4fb2ab6ee2d4f1ad72b99edd36daed1da93a37aa /morphlib/gitdir.py | |
parent | a070b772a565a2803bb1ac4c63a1784cb249ecc3 (diff) | |
download | morph-77d75eb06fa07c64b7e14c376fb6e3742ef33fb3.tar.gz |
GitDir: Add GitDirectory.commit_tree() method
This is used to create commit objects. This is used by build without
commit to provide the behind-the-scenes history.
Diffstat (limited to 'morphlib/gitdir.py')
-rw-r--r-- | morphlib/gitdir.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/morphlib/gitdir.py b/morphlib/gitdir.py index 9020506a..aad507a6 100644 --- a/morphlib/gitdir.py +++ b/morphlib/gitdir.py @@ -17,6 +17,7 @@ import cliapp +import itertools import os import morphlib @@ -242,6 +243,25 @@ class GitDirectory(object): return self._runcmd(['git', 'hash-object', '-t', 'blob', '-w', '--stdin'], **kwargs).strip() + def commit_tree(self, tree, parent, message, **kwargs): + '''Create a commit''' + # NOTE: Will need extension for 0 or N parents. + env = {} + for who, info in itertools.product(('committer', 'author'), + ('name', 'email')): + argname = '%s_%s' % (who, info) + envname = 'GIT_%s_%s' % (who.upper(), info.upper()) + if argname in kwargs: + env[envname] = kwargs[argname] + for who in ('committer', 'author'): + argname = '%s_date' % who + envname = 'GIT_%s_DATE' % who.upper() + if argname in kwargs: + env[envname] = kwargs[argname].isoformat() + return self._runcmd(['git', 'commit-tree', tree, + '-p', parent, '-m', message], + env=env).strip() + def init(dirname): '''Initialise a new git repository.''' |