diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-02-09 21:19:23 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-02-09 21:25:40 +0100 |
commit | 680821b93c007e056c8885fae6ccfd077ddb99a8 (patch) | |
tree | 722f41986afb57ec28904162b4af8c7209c1f2c5 /gbp | |
parent | 0212ccfbfcee55d61058cbe57e69f44510c39b6a (diff) |
Simplify author and committer argument passing
to reduce the number of function arguments.
Git-Dch: Ignore
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/git.py | 42 |
1 files changed, 14 insertions, 28 deletions
@@ -369,23 +369,15 @@ class GitRepository(object): args = [ '-m', msg ] + args GitCommand("update-ref")(args) - def commit_tree(self, tree, msg, parents, author=None, email=None, - date=None, committer_name=None, committer_email=None, - committer_date=None): + def commit_tree(self, tree, msg, parents, author={}, committer={}): """Commit a tree with commit msg 'msg' and parents 'parents'""" extra_env = {} - if author: - extra_env['GIT_AUTHOR_NAME'] = author - if email: - extra_env['GIT_AUTHOR_EMAIL'] = email - if date: - extra_env['GIT_AUTHOR_DATE'] = date - if committer_name: - extra_env['GIT_COMMITTER_NAME'] = committer_name - if committer_email: - extra_env['GIT_COMMITTER_EMAIL'] = committer_email - if committer_date: - extra_env['GIT_COMMITTER_DATE'] = committer_date + for key, val in author.items(): + if val: + extra_env['GIT_AUTHOR_%s' % key.upper()] = val + for key, val in committer.items(): + if val: + extra_env['GIT_COMMITTER_%s' % key.upper()] = val args = [ tree ] for parent in parents: @@ -394,20 +386,17 @@ class GitRepository(object): return sha1 def commit_dir(self, unpack_dir, msg, branch, other_parents=None, - author = None, email = None, date = None, - committer_name = None, committer_email = None, - committer_date = None): + author={}, committer={}): """Replace the current tip of branch 'branch' with the contents from 'unpack_dir' @param unpack_dir: content to add @param msg: commit message to use @param branch: branch to add the contents of unpack_dir to @param parents: additional parents of this commit - @param author: commit with author name 'author' - @param email: commit with author email 'email' - @param date: set author date to 'date' - @param committer_author: commit with committer name 'commiter_name' - @param committer_email: commit with committer email 'commiter_email' - @param committer_date: set commit date to 'date'""" + @param author: commit with author information from author + @type author: dict with keys 'name', 'email', 'date' + @param committer_author: commit with committer information from committer + @type comitter: dict with keys 'name', 'email', 'date'""" + self.__check_path() git_index_file = os.path.join(self.path, '.git', 'gbp_index') try: @@ -436,10 +425,7 @@ class GitRepository(object): parents += [ sha ] commit = self.commit_tree(tree=tree, msg=msg, parents=parents, - author=author, email=email, date=date, - committer_name=committer_name, - committer_email=committer_email, - committer_date=committer_date) + author=author, committer=committer) if not commit: raise GbpError, "Failed to commit tree" self.update_ref("refs/heads/%s" % branch, commit, cur) |