forked from indymedia/epicyon
Extract patch description
parent
0beeb438ca
commit
dc68e2c20b
18
git.py
18
git.py
|
@ -91,6 +91,22 @@ def getGitHash(patchStr: str) -> str:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def getPatchDescription(patchStr: str) -> str:
|
||||||
|
"""Returns the description from a given patch
|
||||||
|
"""
|
||||||
|
patchLines = patchStr.split('\n')
|
||||||
|
description = ''
|
||||||
|
started = False
|
||||||
|
for line in patchLines:
|
||||||
|
if started:
|
||||||
|
if line.strip() == '---':
|
||||||
|
break
|
||||||
|
description += line + '\n'
|
||||||
|
if line.startswith('Subject:'):
|
||||||
|
started = True
|
||||||
|
return description
|
||||||
|
|
||||||
|
|
||||||
def convertPostToPatch(baseDir: str, nickname: str, domain: str,
|
def convertPostToPatch(baseDir: str, nickname: str, domain: str,
|
||||||
postJsonObject: {}) -> bool:
|
postJsonObject: {}) -> bool:
|
||||||
"""Detects whether the given post contains a patch
|
"""Detects whether the given post contains a patch
|
||||||
|
@ -128,7 +144,7 @@ def convertPostToPatch(baseDir: str, nickname: str, domain: str,
|
||||||
postJsonObject['object']['hash'] = commitHash
|
postJsonObject['object']['hash'] = commitHash
|
||||||
postJsonObject['object']['description'] = {
|
postJsonObject['object']['description'] = {
|
||||||
"mediaType": "text/plain",
|
"mediaType": "text/plain",
|
||||||
"content": patchStr
|
"content": getPatchDescription(patchStr)
|
||||||
}
|
}
|
||||||
# remove content map
|
# remove content map
|
||||||
if postJsonObject['object'].get('contentMap'):
|
if postJsonObject['object'].get('contentMap'):
|
||||||
|
|
Loading…
Reference in New Issue