Don't convert post if it doesn't contain a commit hash

main
Bob Mottram 2020-05-03 12:41:05 +00:00
parent e1951b0bad
commit 802fa62e03
1 changed files with 5 additions and 4 deletions

9
git.py
View File

@ -116,15 +116,16 @@ def convertPostToCommit(baseDir: str, nickname: str, domain: str,
postJsonObject['object']['content'], postJsonObject['object']['content'],
False): False):
return False return False
patchStr = gitFormatContent(postJsonObject['object']['content'])
commitHash = getGitHash(patchStr)
if not commitHash:
return False
postJsonObject['object']['type'] = 'Commit' postJsonObject['object']['type'] = 'Commit'
# add a commitedBy parameter # add a commitedBy parameter
if not postJsonObject['object'].get('committedBy'): if not postJsonObject['object'].get('committedBy'):
postJsonObject['object']['committedBy'] = \ postJsonObject['object']['committedBy'] = \
postJsonObject['object']['attributedTo'] postJsonObject['object']['attributedTo']
patchStr = gitFormatContent(postJsonObject['object']['content']) postJsonObject['object']['hash'] = commitHash
commitHash = getGitHash(patchStr)
if commitHash:
postJsonObject['object']['hash'] = commitHash
postJsonObject['object']['description'] = { postJsonObject['object']['description'] = {
"mediaType": "text/plain", "mediaType": "text/plain",
"content": patchStr "content": patchStr