diff options
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/git/repository.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 43a8c46d..1c6fc34d 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -917,6 +917,31 @@ class GitRepository(object): else: return [] + + def write_file(self, filename, filters=True): + """ + Hash a single file and write it into the object database + + @param filename: the filename to the content of the file to hash + @type filename: C{str} + @param filters: whether to run filters + @type filters: C{bool} + @return: the hash of the file + @rtype: C{str} + """ + args = GitArgs('-w', '-t', 'blob') + args.add_false(filters, '--no-filters') + args.add(filename) + + sha1, stderr, ret = self._git_inout('hash-object', + args.args, + capture_stderr=True) + if not ret: + return sha1.strip() + else: + raise GbpError("Failed to hash %s: %s" % (filename, stderr)) +#} + #{ Comitting def _commit(self, msg, args=[], author_info=None): |