diff options
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.''' |