diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2016-11-09 10:08:13 +0000 |
---|---|---|
committer | Thibault Saunier <thibault.saunier@osg.samsung.com> | 2016-11-09 09:54:49 -0300 |
commit | 8a2cac12e2c1805e05c45a52d72beb8b25b7e0df (patch) | |
tree | c39327e774910385b0cf5e6d204f80d2b1a7faee | |
parent | 5293c3dc41cc32f095397bfe4102fef3cad94b79 (diff) |
git-phab: Fix additions and deletions of binary files
The code was only handling changes to, or renames of, binary files.
Additionally, it was never uploading the old binary file, so these
changes were appearing as file additions.
Signed-off-by: Philip Withnall <philip.withnall@collabora.co.uk>
Reviewed-by: Thibault Saunier <tsaunier@gnome.org>
Differential Revision: https://phabricator.freedesktop.org/D1455
-rwxr-xr-x | git-phab | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -875,16 +875,29 @@ Paste API Token from that page and press <enter>: """ % self.phabricator_uri) filetype = "1" else: hunks = [] - phab_file = self.phabricator.file.upload( - data_base64=base64.standard_b64encode( - diff.b_blob.data_stream[-1].read()).decode("utf-8")) + + if not diff.deleted_file: + b_phab_file = self.phabricator.file.upload( + data_base64=base64.standard_b64encode( + diff.b_blob.data_stream[-1].read()).decode("utf-8")) + else: + b_phab_file = None + + if not diff.new_file: + a_phab_file = self.phabricator.file.upload( + data_base64=base64.standard_b64encode( + diff.a_blob.data_stream[-1].read()).decode("utf-8")) + else: + a_phab_file = None filetype = "3" metadata = { "old:file:size": diff.a_blob.size if diff.a_blob else 0, + "old:file:mime-type": diff.a_blob.mime_type if diff.a_blob else '', + "old:binary-phid": a_phab_file.response if a_phab_file else '', "new:file:size": diff.b_blob.size if diff.b_blob else 0, - "new:file:mime-type": diff.b_blob.mime_type, - "new:binary-phid": phab_file.response + "new:file:mime-type": diff.b_blob.mime_type if diff.b_blob else '', + "new:binary-phid": b_phab_file.response if b_phab_file else '', } return change_filename, {"metadata": metadata, |