Skip to content

Improve codebase's message template #873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 7 additions & 23 deletions zulip/integrations/codebase/zulip_codebase_mirror
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ user_agent = "Codebase To Zulip Mirroring script ([email protected])"
# find some form of JSON loader/dumper, with a preference order for speed.
json_implementations = ["ujson", "cjson", "simplejson", "json"]

while len(json_implementations):
while json_implementations:
try:
json = __import__(json_implementations.pop(0))
break
Expand Down Expand Up @@ -121,16 +121,11 @@ def handle_event(event: Dict[str, Any]) -> None:
subject = f"Push to {branch} on {project}"

if deleted_ref:
content = f"{actor_name} deleted branch {branch} from {project}"
content = f"{actor_name} deleted branch `{branch}` from {project}"
else:
if new_ref:
branch = f"new branch {branch}"
content = "{} pushed {} commit(s) to {} in project {}:\n\n".format(
actor_name,
num_commits,
branch,
project,
)
branch = f"new branch `{branch}`"
content = f"{actor_name} pushed {num_commits} commit(s) to `{branch}` in project {project}:\n\n"
for commit in raw_props.get("commits"):
ref = commit.get("ref")
url = make_url(f"projects/{project_link}/repositories/{repo_link}/commit/{ref}")
Expand Down Expand Up @@ -162,11 +157,8 @@ def handle_event(event: Dict[str, Any]) -> None:

content = ""
if body is not None and len(body) > 0:
content = "{} added a comment to ticket [#{}]({}):\n\n~~~ quote\n{}\n\n".format(
actor_name,
num,
url,
body,
content = (
f"{actor_name} added a comment to ticket [#{num}]({url}):\n\n~~~ quote\n{body}\n\n"
)

if "status_id" in changes:
Expand Down Expand Up @@ -228,15 +220,7 @@ def handle_event(event: Dict[str, Any]) -> None:

subject = f"Deployment to {environment}"

content = "{} deployed [{}]({}) [through]({}) [{}]({}) to the **{}** environment.".format(
actor_name,
start_ref,
start_ref_url,
between_url,
end_ref,
end_ref_url,
environment,
)
content = f"{actor_name} deployed [{start_ref}]({start_ref_url}) [through]({between_url}) [{end_ref}]({end_ref_url}) to the **{environment}** environment."
if servers is not None:
content += "\n\nServers deployed to: %s" % (
", ".join(f"`{server}`" for server in servers)
Expand Down
Loading