in notifier.py [0:0]
def get_custom_subject(self, repository, action="catchall"):
"""Gets a subject template for a specific action, if specified via .asf.yaml"""
# Rewrite some unintuitively named github actions to more human friendly ones.
action_map = {
"created_issue": "comment_issue",
"created_pr": "comment_pr",
"diffcomment_collated_pr": "diffcomment",
"open_issue": "new_issue",
"open_pr": "new_pr",
}
if action in action_map:
action = action_map[action]
ymlfile = f"/x1/asfyaml/ghsettings.{repository}.yml" # Path to github settings yaml file
if os.path.isfile(ymlfile):
try:
yml = yaml.safe_load(open(ymlfile))
except yaml.parser.ParserError: # Invalid YAML?!
return
custom_subjects = yml.get("custom_subjects")
if custom_subjects and isinstance(custom_subjects, dict):
if action in custom_subjects:
return custom_subjects[action]
elif "catchall" in custom_subjects: # If no custom subject exists for this action, but catchall does...
return custom_subjects["catchall"]