refactor(formatter/buildbot): cleanup redundancy in logic
This commit is contained in:
parent
97e10df1a2
commit
8c18c2054e
1 changed files with 6 additions and 13 deletions
|
@ -9,28 +9,21 @@ def formatter(data, headers):
|
||||||
reason = data["buildset"]["reason"]
|
reason = data["buildset"]["reason"]
|
||||||
project = data["properties"]["project"][0]
|
project = data["properties"]["project"][0]
|
||||||
submittime = datetime.fromtimestamp(data["buildset"]["submitted_at"])
|
submittime = datetime.fromtimestamp(data["buildset"]["submitted_at"])
|
||||||
# This could use some optimization, but it works for now.
|
|
||||||
if buildstate == "starting":
|
|
||||||
try:
|
try:
|
||||||
|
if buildstate == "starting":
|
||||||
data["body"] = (
|
data["body"] = (
|
||||||
f"###Buildbot job #{buildid} for {project} - {buildstate}\n\n"
|
f"###Buildbot job #{buildid} for {project} - {buildstate}\n\n"
|
||||||
f"{reason}\n\n"
|
f"{reason}\n\n"
|
||||||
f"**started at** {submittime}\n\n"
|
f"**started at** {submittime}\n\n"
|
||||||
f"[view details]({buildlink})"
|
f"[view details]({buildlink})"
|
||||||
)
|
)
|
||||||
except Exception as error:
|
|
||||||
print(error)
|
|
||||||
elif buildstate == "build successful":
|
elif buildstate == "build successful":
|
||||||
try:
|
|
||||||
data["body"] = (
|
data["body"] = (
|
||||||
f"###Buildbot job #{buildid} for {project} - {buildstate}\n\n"
|
f"###Buildbot job #{buildid} for {project} - {buildstate}\n\n"
|
||||||
f"**completed at** {datetime.fromtimestamp(data['complete_at'])}\n\n"
|
f"**completed at** {datetime.fromtimestamp(data['complete_at'])}\n\n"
|
||||||
f"[view details]({buildlink})"
|
f"[view details]({buildlink})"
|
||||||
)
|
)
|
||||||
except Exception as error:
|
|
||||||
print(error)
|
|
||||||
else:
|
else:
|
||||||
try:
|
|
||||||
data["body"] = (
|
data["body"] = (
|
||||||
f"###Buildbot job #{buildid} for {project} - {buildstate}\n\n"
|
f"###Buildbot job #{buildid} for {project} - {buildstate}\n\n"
|
||||||
f"[view details]({buildlink})"
|
f"[view details]({buildlink})"
|
||||||
|
|
Loading…
Reference in a new issue