コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
ファイル: view.py プロジェクト: lakshyaTaragi/zulip
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}
コード例 #4
0
ファイル: github.py プロジェクト: galexrt/zulip
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
コード例 #5
0
ファイル: view.py プロジェクト: gnprice/zulip
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
コード例 #6
0
ファイル: view.py プロジェクト: akashnimare/zulip
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
コード例 #7
0
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),
    )
コード例 #8
0
ファイル: view.py プロジェクト: buyrs/demozy
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"],
    )
コード例 #9
0
ファイル: view.py プロジェクト: eliasdorneles/zulip
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)
    )
コード例 #10
0
ファイル: view.py プロジェクト: brockwhittaker/zulip
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'],
    )
コード例 #11
0
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'],
    )
コード例 #12
0
ファイル: gitlab.py プロジェクト: galexrt/zulip
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)
    )
コード例 #13
0
ファイル: view.py プロジェクト: gregmccoy/zulip
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)
    )
コード例 #14
0
ファイル: view.py プロジェクト: umairwaheed/zulip
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'],
    )
コード例 #15
0
ファイル: view.py プロジェクト: vineetb95/zulip
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))
コード例 #16
0
ファイル: view.py プロジェクト: priyank-p/zulip
def get_remove_branch_event_body(payload: WildValue) -> str:
    return get_remove_branch_event_message(
        get_user_name(payload),
        get_branch_name(payload),
    )
コード例 #17
0
ファイル: bitbucket2.py プロジェクト: zebesta/zulip
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'],
    )