From faf08400b1827aec45aa4b84fe05ed3d2235a0c7 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont <nicolas@dandrimont.eu> Date: Tue, 29 Mar 2016 17:37:06 +0200 Subject: [PATCH] identifiers: support None messages in revisions and releases --- swh/model/identifiers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/swh/model/identifiers.py b/swh/model/identifiers.py index 90f3db0a..04f8b6e8 100644 --- a/swh/model/identifiers.py +++ b/swh/model/identifiers.py @@ -288,7 +288,8 @@ def revision_identifier(revision): Multiline extra header values are escaped by indenting the continuation lines with one ascii space. - The headers are separated from the commit message with an empty line. + If the message is None, the manifest ends with the last header. Else, the + message is appended to the headers after an empty line. The checksum of the full manifest is computed using the 'commit' git object type. @@ -330,7 +331,8 @@ def revision_identifier(revision): # encode the key to utf-8 components.extend([key.encode('utf-8'), b' ', value, b'\n']) - components.extend([b'\n', revision['message']]) + if revision['message'] is not None: + components.extend([b'\n', revision['message']]) commit_raw = b''.join(components) return identifier_to_str(hash_git_data(commit_raw, 'commit')) @@ -360,6 +362,7 @@ def release_identifier(release): format_date_offset(release['date']), b'\n', ]) - components.extend([b'\n', release['message']]) + if release['message'] is not None: + components.extend([b'\n', release['message']]) return identifier_to_str(hash_git_data(b''.join(components), 'tag')) -- GitLab