def build_message_from_gitlog( user_profile: UserProfile, name: str, ref: str, commits: List[Dict[str, str]], before: str, after: str, url: str, pusher: str, forced: Optional[str] = None, created: Optional[str] = None, deleted: Optional[bool] = False) -> Tuple[str, str]: short_ref = re.sub(r'^refs/heads/', '', ref) subject = SUBJECT_WITH_BRANCH_TEMPLATE.format(repo=name, branch=short_ref) if re.match(r'^0+$', after): content = get_remove_branch_event_message(pusher, short_ref) # 'created' and 'forced' are github flags; the second check is for beanstalk elif (forced and not created) or (forced is None and len(commits) == 0): content = get_force_push_commits_event_message(pusher, url, short_ref, after[:7]) else: commits = _transform_commits_list_to_common_format(commits) try: content = get_push_commits_event_message(pusher, url, short_ref, commits, deleted=deleted) except TypeError: # nocoverage This error condition seems to # be caused by a change in GitHub's APIs. Since we've # deprecated this webhook, just suppress them with a 40x error. raise JsonableError("Malformed commit data") return subject, content
def build_message_from_gitlog(user_profile, name, ref, commits, before, after, url, pusher, forced=None, created=None, deleted=False): # type: (UserProfile, Text, Text, List[Dict[str, str]], Text, Text, Text, Text, Optional[Text], Optional[Text], Optional[bool]) -> Tuple[Text, Text] short_ref = re.sub(r'^refs/heads/', '', ref) subject = SUBJECT_WITH_BRANCH_TEMPLATE.format(repo=name, branch=short_ref) if re.match(r'^0+$', after): content = get_remove_branch_event_message(pusher, short_ref) # 'created' and 'forced' are github flags; the second check is for beanstalk elif (forced and not created) or (forced is None and len(commits) == 0): content = get_force_push_commits_event_message(pusher, url, short_ref, after[:7]) else: commits = _transform_commits_list_to_common_format(commits) content = get_push_commits_event_message(pusher, url, short_ref, commits, deleted=deleted) return subject, content
def repo_push_branch_data(payload: Dict[str, Any], change: Dict[str, Any]) -> Dict[str, str]: event_type = change["type"] repo_name = payload["repository"]["name"] user_name = get_user_name(payload) branch_name = change["ref"]["displayId"] branch_head = change["toHash"] if event_type == "ADD": body = get_create_branch_event_message( user_name=user_name, url=None, branch_name=branch_name, ) elif event_type == "UPDATE": body = BRANCH_UPDATED_MESSAGE_TEMPLATE.format( user_name=user_name, branch_name=branch_name, head=branch_head, ) elif event_type == "DELETE": body = get_remove_branch_event_message(user_name, branch_name) else: message = "{}.{}".format(payload["eventKey"], event_type) # nocoverage raise UnsupportedWebhookEventType(message) subject = TOPIC_WITH_BRANCH_TEMPLATE.format(repo=repo_name, branch=branch_name) return {"subject": subject, "body": body}
def build_message_from_gitlog(user_profile, name, ref, commits, before, after, url, pusher, forced=None, created=None): # type: (UserProfile, text_type, text_type, List[Dict[str, str]], text_type, text_type, text_type, text_type, Optional[text_type], Optional[text_type]) -> Tuple[text_type, text_type] short_ref = re.sub(r"^refs/heads/", "", ref) subject = SUBJECT_WITH_BRANCH_TEMPLATE.format(repo=name, branch=short_ref) if re.match(r"^0+$", after): content = get_remove_branch_event_message(pusher, short_ref) # 'created' and 'forced' are github flags; the second check is for beanstalk elif (forced and not created) or (forced is None and len(commits) == 0): content = get_force_push_commits_event_message(pusher, url, short_ref, after[:7]) else: commits = _transform_commits_list_to_common_format(commits) content = get_push_commits_event_message(pusher, url, short_ref, commits) return subject, content
def build_message_from_gitlog(user_profile: UserProfile, name: Text, ref: Text, commits: List[Dict[str, str]], before: Text, after: Text, url: Text, pusher: Text, forced: Optional[Text]=None, created: Optional[Text]=None, deleted: Optional[bool]=False ) -> Tuple[Text, Text]: short_ref = re.sub(r'^refs/heads/', '', ref) subject = SUBJECT_WITH_BRANCH_TEMPLATE.format(repo=name, branch=short_ref) if re.match(r'^0+$', after): content = get_remove_branch_event_message(pusher, short_ref) # 'created' and 'forced' are github flags; the second check is for beanstalk elif (forced and not created) or (forced is None and len(commits) == 0): content = get_force_push_commits_event_message(pusher, url, short_ref, after[:7]) else: commits = _transform_commits_list_to_common_format(commits) content = get_push_commits_event_message(pusher, url, short_ref, commits, deleted=deleted) return subject, content
def build_message_from_gitlog(user_profile: UserProfile, name: str, ref: str, commits: List[Dict[str, str]], before: str, after: str, url: str, pusher: str, forced: Optional[str]=None, created: Optional[str]=None, deleted: Optional[bool]=False ) -> Tuple[str, str]: short_ref = re.sub(r'^refs/heads/', '', ref) subject = TOPIC_WITH_BRANCH_TEMPLATE.format(repo=name, branch=short_ref) if re.match(r'^0+$', after): content = get_remove_branch_event_message(pusher, short_ref) # 'created' and 'forced' are github flags; the second check is for beanstalk elif (forced and not created) or (forced is None and len(commits) == 0): content = get_force_push_commits_event_message(pusher, url, short_ref, after[:7]) else: commits = _transform_commits_list_to_common_format(commits) try: content = get_push_commits_event_message(pusher, url, short_ref, commits, deleted=deleted) except TypeError: # nocoverage This error condition seems to # be caused by a change in GitHub's APIs. Since we've # deprecated this webhook, just suppress them with a 40x error. raise JsonableError( "Malformed commit data") return subject, content
def get_remove_branch_push_body(payload: WildValue, change: WildValue) -> str: return get_remove_branch_event_message( get_actor_info(payload), change["old"]["name"].tame(check_string), )
def get_remove_branch_push_body(payload: Dict[str, Any], change: Dict[str, Any]) -> str: return get_remove_branch_event_message( get_actor_info(payload), change["old"]["name"], )
def get_remove_branch_event_body(payload): # type: (Dict[str, Any]) -> Text return get_remove_branch_event_message( get_user_name(payload), get_branch_name(payload) )
def get_remove_branch_push_body(payload, change): # type: (Dict[str, Any], Dict[str, Any]) -> Text return get_remove_branch_event_message( get_user_username(payload), change['old']['name'], )
def get_remove_branch_push_body(payload: Dict[str, Any], change: Dict[str, Any]) -> str: return get_remove_branch_event_message( get_user_username(payload), change['old']['name'], )
def get_remove_branch_event_body(payload): # type: (Dict[str, Any]) -> text_type return get_remove_branch_event_message( get_user_name(payload), get_branch_name(payload) )
def get_remove_branch_event_body(payload: Dict[str, Any]) -> str: return get_remove_branch_event_message( get_user_name(payload), get_branch_name(payload) )
def get_remove_branch_event_body(payload: Dict[str, Any]) -> str: return get_remove_branch_event_message(get_user_name(payload), get_branch_name(payload))
def get_remove_branch_event_body(payload: WildValue) -> str: return get_remove_branch_event_message( get_user_name(payload), get_branch_name(payload), )
def get_remove_branch_push_body(payload, change): # type: (Dict[str, Any], Dict[str, Any]) -> text_type return get_remove_branch_event_message( get_user_username(payload), change['old']['name'], )