예제 #1
0
파일: view.py 프로젝트: gnprice/zulip
def get_pull_request_review_body(payload: Dict[str, Any]) -> Text:
    return get_pull_request_event_message(
        get_sender_name(payload),
        'submitted',
        payload['review']['html_url'],
        type='PR Review'
    )
예제 #2
0
파일: view.py 프로젝트: joydeep1701/zulip
def get_pull_request_action_body(payload: Dict[str, Any], action: str) -> Text:
    pull_request = payload['pullrequest']
    return get_pull_request_event_message(
        get_user_username(payload),
        action,
        get_pull_request_url(pull_request),
        pull_request.get('id')
    )
예제 #3
0
파일: view.py 프로젝트: gnprice/zulip
def get_closed_pull_request_body(payload: Dict[str, Any]) -> Text:
    pull_request = payload['pull_request']
    action = 'merged' if pull_request['merged'] else 'closed without merge'
    return get_pull_request_event_message(
        get_sender_name(payload),
        action,
        pull_request['html_url'],
    )
예제 #4
0
def get_pull_request_action_body(payload, action):
    # type: (Dict[str, Any], str) -> text_type
    pull_request = payload['pullrequest']
    return get_pull_request_event_message(
        get_user_username(payload),
        action,
        get_pull_request_url(pull_request),
    )
예제 #5
0
파일: github.py 프로젝트: galexrt/zulip
def github_object_commented_content(payload, type):
    # type: (Mapping[text_type, Any], text_type) -> text_type
    comment = payload["comment"]
    issue = payload["issue"]
    action = u"[commented]({}) on".format(comment["html_url"])

    return get_pull_request_event_message(
        comment["user"]["login"], action, issue["html_url"], issue["number"], message=comment["body"], type=type
    )
예제 #6
0
파일: view.py 프로젝트: joydeep1701/zulip
def get_pull_request_comment_action_body(payload: Dict[str, Any], action: str) -> Text:
    action += ' on'
    return get_pull_request_event_message(
        get_user_username(payload),
        action,
        payload['pullrequest']['links']['html']['href'],
        payload['pullrequest']['id'],
        message=payload['comment']['content']['raw']
    )
예제 #7
0
파일: gitlab.py 프로젝트: timabbott/zulip
def get_merge_request_event_body(payload, action):
    # type: (Dict[str, Any], text_type) -> text_type
    pull_request = payload.get('object_attributes')
    return get_pull_request_event_message(
        get_issue_user_name(payload),
        action,
        pull_request.get('url'),
        type='MR',
    )
예제 #8
0
파일: view.py 프로젝트: joydeep1701/zulip
def get_merge_request_event_body(payload: Dict[str, Any], action: Text) -> Text:
    pull_request = payload['object_attributes']
    return get_pull_request_event_message(
        get_issue_user_name(payload),
        action,
        pull_request.get('url'),
        pull_request.get('iid'),
        type='MR',
    )
예제 #9
0
파일: view.py 프로젝트: brainwane/zulip
def get_pull_request_action_body(payload: Dict[str, Any], action: str,
                                 include_title: Optional[bool]=False) -> str:
    pull_request = payload['pullrequest']
    return get_pull_request_event_message(
        get_user_username(payload),
        action,
        get_pull_request_url(pull_request),
        pull_request.get('id'),
        title=pull_request['title'] if include_title else None
    )
예제 #10
0
파일: github.py 프로젝트: galexrt/zulip
def github_pull_request_content(payload):
    # type: (Mapping[text_type, Any]) -> text_type
    pull_request = payload["pull_request"]
    action = get_pull_request_or_issue_action(payload)

    if action in ("opened", "edited"):
        return get_pull_request_event_message(
            payload["sender"]["login"],
            action,
            pull_request["html_url"],
            pull_request["number"],
            pull_request["head"]["ref"],
            pull_request["base"]["ref"],
            pull_request["body"],
            get_pull_request_or_issue_assignee(pull_request),
        )
    return get_pull_request_event_message(
        payload["sender"]["login"], action, pull_request["html_url"], pull_request["number"]
    )
예제 #11
0
파일: github.py 프로젝트: timabbott/zulip
def github_pull_request_content(payload):
    # type: (Mapping[text_type, Any]) -> text_type
    pull_request = payload['pull_request']
    action = get_pull_request_or_issue_action(payload)

    if action in ('opened', 'edited'):
        return get_pull_request_event_message(
            payload['sender']['login'],
            action,
            pull_request['html_url'],
            pull_request['head']['ref'],
            pull_request['base']['ref'],
            pull_request['body'],
            get_pull_request_or_issue_assignee(pull_request)
        )
    return get_pull_request_event_message(
            payload['sender']['login'],
            action,
            pull_request['html_url'],
        )
예제 #12
0
파일: view.py 프로젝트: gregmccoy/zulip
def get_merge_request_event_body(payload: Dict[str, Any], action: str,
                                 include_title: Optional[bool]=False) -> str:
    pull_request = payload['object_attributes']
    return get_pull_request_event_message(
        get_issue_user_name(payload),
        action,
        pull_request.get('url'),
        pull_request.get('iid'),
        type='MR',
        title=payload['object_attributes'].get('title') if include_title else None
    )
예제 #13
0
파일: view.py 프로젝트: gregmccoy/zulip
def get_closed_pull_request_body(payload: Dict[str, Any],
                                 include_title: Optional[bool]=False) -> str:
    pull_request = payload['pull_request']
    action = 'merged' if pull_request['merged'] else 'closed without merge'
    return get_pull_request_event_message(
        get_sender_name(payload),
        action,
        pull_request['html_url'],
        number=pull_request['number'],
        title=pull_request['title'] if include_title else None
    )
예제 #14
0
파일: view.py 프로젝트: gnprice/zulip
def get_pull_request_review_comment_body(payload: Dict[str, Any]) -> Text:
    action = payload['action']
    message = None
    if action == 'created':
        message = payload['comment']['body']

    return get_pull_request_event_message(
        get_sender_name(payload),
        action,
        payload['comment']['html_url'],
        message=message,
        type='PR Review Comment'
    )
예제 #15
0
파일: view.py 프로젝트: joydeep1701/zulip
def get_merge_request_open_or_updated_body(payload: Dict[str, Any], action: Text) -> Text:
    pull_request = payload['object_attributes']
    return get_pull_request_event_message(
        get_issue_user_name(payload),
        action,
        pull_request.get('url'),
        pull_request.get('iid'),
        pull_request.get('source_branch'),
        pull_request.get('target_branch'),
        pull_request.get('description'),
        get_objects_assignee(payload),
        type='MR',
    )
예제 #16
0
파일: view.py 프로젝트: brainwane/zulip
def get_pull_request_comment_action_body(
        payload: Dict[str, Any], action: str,
        include_title: Optional[bool]=False
) -> str:
    action += ' on'
    return get_pull_request_event_message(
        get_user_username(payload),
        action,
        payload['pullrequest']['links']['html']['href'],
        payload['pullrequest']['id'],
        message=payload['comment']['content']['raw'],
        title=payload['pullrequest']['title'] if include_title else None
    )
예제 #17
0
파일: github.py 프로젝트: timabbott/zulip
def github_object_commented_content(payload, type):
    # type: (Mapping[text_type, Any], text_type) -> text_type
    comment = payload['comment']
    issue = payload['issue']
    action = u'[commented]({})'.format(comment['html_url'])

    return get_pull_request_event_message(
        comment['user']['login'],
        action,
        issue['html_url'],
        message=comment['body'],
        type=type
    )
예제 #18
0
파일: view.py 프로젝트: gregmccoy/zulip
def get_pull_request_review_body(payload: Dict[str, Any],
                                 include_title: Optional[bool]=False) -> str:
    title = "for #{} {}".format(
        payload['pull_request']['number'],
        payload['pull_request']['title']
    )
    return get_pull_request_event_message(
        get_sender_name(payload),
        'submitted',
        payload['review']['html_url'],
        type='PR Review',
        title=title if include_title else None
    )
예제 #19
0
파일: gitlab.py 프로젝트: timabbott/zulip
def get_merge_request_open_or_updated_body(payload, action):
    # type: (Dict[str, Any], text_type) -> text_type
    pull_request = payload.get('object_attributes')
    return get_pull_request_event_message(
        get_issue_user_name(payload),
        action,
        pull_request.get('url'),
        pull_request.get('source_branch'),
        pull_request.get('target_branch'),
        pull_request.get('description'),
        get_objects_assignee(payload),
        type='MR',
    )
예제 #20
0
파일: view.py 프로젝트: yhl-python/zulip
def get_assigned_or_unassigned_pull_request_body(payload):
    # type: (Dict[str, Any]) -> Text
    pull_request = payload['pull_request']
    assignee = pull_request.get('assignee', {}).get('login')

    base_message = get_pull_request_event_message(
        get_sender_name(payload),
        payload['action'],
        pull_request['html_url'],
    )
    if assignee:
        return "{} to {}".format(base_message, assignee)
    return base_message
예제 #21
0
파일: view.py 프로젝트: akashnimare/zulip
def github_object_commented_content(payload: Mapping[str, Any], type: str) -> str:
    comment = payload['comment']
    issue = payload['issue']
    action = u'[commented]({}) on'.format(comment['html_url'])

    return get_pull_request_event_message(
        comment['user']['login'],
        action,
        issue['html_url'],
        issue['number'],
        message=comment['body'],
        type=type
    )
예제 #22
0
파일: view.py 프로젝트: umairwaheed/zulip
def get_assigned_or_unassigned_pull_request_body(payload: Dict[str, Any]) -> str:
    pull_request = payload['pull_request']
    assignee = pull_request.get('assignee')
    if assignee is not None:
        assignee = assignee.get('login')

    base_message = get_pull_request_event_message(
        get_sender_name(payload),
        payload['action'],
        pull_request['html_url'],
    )
    if assignee is not None:
        return "{} to {}".format(base_message, assignee)
    return base_message
예제 #23
0
파일: view.py 프로젝트: gregmccoy/zulip
def get_merge_request_open_or_updated_body(payload: Dict[str, Any], action: str,
                                           include_title: Optional[bool]=False) -> str:
    pull_request = payload['object_attributes']
    return get_pull_request_event_message(
        get_issue_user_name(payload),
        action,
        pull_request.get('url'),
        pull_request.get('iid'),
        pull_request.get('source_branch'),
        pull_request.get('target_branch'),
        pull_request.get('description'),
        get_objects_assignee(payload),
        type='MR',
        title=payload['object_attributes'].get('title') if include_title else None
    )
예제 #24
0
파일: view.py 프로젝트: joydeep1701/zulip
def get_commented_snippet_event_body(payload: Dict[str, Any]) -> Text:
    comment = payload['object_attributes']
    action = u'[commented]({}) on'.format(comment['url'])
    url = u'{}/snippets/{}'.format(
        payload['project'].get('web_url'),
        payload['snippet'].get('id')
    )
    return get_pull_request_event_message(
        get_issue_user_name(payload),
        action,
        url,
        payload['snippet'].get('id'),
        message=comment['note'],
        type='Snippet'
    )
예제 #25
0
파일: view.py 프로젝트: joydeep1701/zulip
def get_pull_request_created_or_updated_body(payload: Dict[str, Any], action: str) -> Text:
    pull_request = payload['pullrequest']
    assignee = None
    if pull_request.get('reviewers'):
        assignee = pull_request.get('reviewers')[0]['username']

    return get_pull_request_event_message(
        get_user_username(payload),
        action,
        get_pull_request_url(pull_request),
        pull_request.get('id'),
        target_branch=pull_request['source']['branch']['name'],
        base_branch=pull_request['destination']['branch']['name'],
        message=pull_request['description'],
        assignee=assignee
    )
예제 #26
0
파일: gitlab.py 프로젝트: galexrt/zulip
def get_commented_issue_event_body(payload):
    # type: (Dict[str, Any]) -> text_type
    comment = payload.get('object_attributes')
    action = u'[commented]({}) on'.format(comment['url'])
    url = u'{}/issues/{}'.format(
        payload.get('project').get('web_url'),
        payload.get('issue').get('iid')
    )
    return get_pull_request_event_message(
        get_issue_user_name(payload),
        action,
        url,
        payload.get('issue').get('iid'),
        message=comment['note'],
        type='Issue'
    )
예제 #27
0
파일: view.py 프로젝트: joydeep1701/zulip
def format_pull_request_event(payload: Dict[str, Any]) -> Text:

    data = {
        'user_name': payload['pull_request']['user']['username'],
        'action': payload['action'],
        'url': payload['pull_request']['html_url'],
        'number': payload['pull_request']['number'],
        'target_branch': payload['pull_request']['head_branch'],
        'base_branch': payload['pull_request']['base_branch'],
    }

    if payload['pull_request']['merged']:
        data['user_name'] = payload['pull_request']['merged_by']['username']
        data['action'] = 'merged'

    return get_pull_request_event_message(**data)
예제 #28
0
파일: view.py 프로젝트: gregmccoy/zulip
def get_assigned_or_unassigned_pull_request_body(payload: Dict[str, Any],
                                                 include_title: Optional[bool]=False) -> str:
    pull_request = payload['pull_request']
    assignee = pull_request.get('assignee')
    if assignee is not None:
        assignee = assignee.get('login')

    base_message = get_pull_request_event_message(
        get_sender_name(payload),
        payload['action'],
        pull_request['html_url'],
        number=pull_request['number'],
        title=pull_request['title'] if include_title else None
    )
    if assignee is not None:
        return "{} to {}".format(base_message, assignee)
    return base_message
예제 #29
0
파일: view.py 프로젝트: gnprice/zulip
def get_opened_or_update_pull_request_body(payload: Dict[str, Any]) -> Text:
    pull_request = payload['pull_request']
    action = payload['action']
    if action == 'synchronize':
        action = 'updated'
    assignee = None
    if pull_request.get('assignee'):
        assignee = pull_request['assignee']['login']

    return get_pull_request_event_message(
        get_sender_name(payload),
        action,
        pull_request['html_url'],
        target_branch=pull_request['head']['ref'],
        base_branch=pull_request['base']['ref'],
        message=pull_request['body'],
        assignee=assignee
    )
예제 #30
0
파일: view.py 프로젝트: akashnimare/zulip
def format_pull_request_event(payload: Dict[str, Any],
                              include_title: Optional[bool]=False) -> str:

    data = {
        'user_name': payload['pull_request']['user']['username'],
        'action': payload['action'],
        'url': payload['pull_request']['html_url'],
        'number': payload['pull_request']['number'],
        'target_branch': payload['pull_request']['head_branch'],
        'base_branch': payload['pull_request']['base_branch'],
        'title': payload['pull_request']['title'] if include_title else None
    }

    if payload['pull_request']['merged']:
        data['user_name'] = payload['pull_request']['merged_by']['username']
        data['action'] = 'merged'

    return get_pull_request_event_message(**data)
예제 #31
0
def get_pull_request_review_comment_body(helper: Helper) -> str:
    payload = helper.payload
    include_title = helper.include_title
    action = payload["action"]
    message = None
    if action == "created":
        message = payload["comment"]["body"]

    title = "on #{} {}".format(
        payload["pull_request"]["number"],
        payload["pull_request"]["title"],
    )

    return get_pull_request_event_message(
        get_sender_name(payload),
        action,
        payload["comment"]["html_url"],
        message=message,
        type="PR Review Comment",
        title=title if include_title else None,
    )
예제 #32
0
def pr_comment_handler(payload: Dict[str, Any],
                       action: str,
                       include_title: bool = False) -> List[Dict[str, str]]:
    pr = payload["pullRequest"]
    subject = get_pr_subject(pr["toRef"]["repository"]["name"],
                             type="PR",
                             id=pr["id"],
                             title=pr["title"])
    message = payload["comment"]["text"]
    if action == "deleted their comment on":
        message = f"~~{message}~~"
    body = get_pull_request_event_message(
        user_name=get_user_name(payload),
        action=action,
        url=pr["links"]["self"][0]["href"],
        number=pr["id"],
        message=message,
        title=pr["title"] if include_title else None,
    )

    return [{"subject": subject, "body": body}]
예제 #33
0
def get_pr_opened_or_modified_body(payload: Dict[str, Any], action: str,
                                   include_title: Optional[bool]) -> str:
    pr = payload["pullRequest"]
    description = pr.get("description")
    assignees_string = get_assignees_string(pr)
    if assignees_string:
        # Then use the custom message template for this particular integration so that we can
        # specify the reviewers at the end of the message (but before the description/message).
        parameters = {
            "user_name": get_user_name(payload),
            "action": action,
            "url": pr["links"]["self"][0]["href"],
            "number": pr["id"],
            "source": pr["fromRef"]["displayId"],
            "destination": pr["toRef"]["displayId"],
            "message": description,
            "assignees": assignees_string,
            "title": pr["title"] if include_title else None
        }
        if include_title:
            body = PULL_REQUEST_OPENED_OR_MODIFIED_TEMPLATE_WITH_REVIEWERS_WITH_TITLE.format(
                **parameters)
        else:
            body = PULL_REQUEST_OPENED_OR_MODIFIED_TEMPLATE_WITH_REVIEWERS.format(
                **parameters)
        punctuation = ':' if description else '.'
        body = "{}{}".format(body, punctuation)
        if description:
            body += '\n' + CONTENT_MESSAGE_TEMPLATE.format(message=description)
        return body
    return get_pull_request_event_message(
        user_name=get_user_name(payload),
        action=action,
        url=pr["links"]["self"][0]["href"],
        number=pr["id"],
        target_branch=pr["fromRef"]["displayId"],
        base_branch=pr["toRef"]["displayId"],
        message=pr.get("description"),
        assignee=assignees_string if assignees_string else None,
        title=pr["title"] if include_title else None)
예제 #34
0
def get_pull_request_created_or_updated_body(payload: Dict[str, Any], action: str,
                                             include_title: bool=False) -> str:
    pull_request = payload['pullrequest']
    assignee = None
    if pull_request.get('reviewers'):
        assignee = pull_request.get('reviewers')[0]
        # Certain payloads may not contain a username, so we
        # return the user's display name or nickname instead.
        assignee = (assignee.get('username') or assignee.get('display_name') or
                    assignee.get('nickname'))

    return get_pull_request_event_message(
        get_user_username(payload),
        action,
        get_pull_request_url(pull_request),
        pull_request.get('id'),
        target_branch=pull_request['source']['branch']['name'],
        base_branch=pull_request['destination']['branch']['name'],
        message=pull_request['description'],
        assignee=assignee,
        title=pull_request['title'] if include_title else None,
    )
예제 #35
0
def format_pull_request_event(payload: WildValue, include_title: bool = False) -> str:
    if payload["pull_request"]["merged"].tame(check_bool):
        user_name = payload["pull_request"]["merged_by"]["username"].tame(check_string)
        action = "merged"
    else:
        user_name = payload["pull_request"]["user"]["username"].tame(check_string)
        action = payload["action"].tame(check_string)
    url = payload["pull_request"]["html_url"].tame(check_string)
    number = payload["pull_request"]["number"].tame(check_int)
    target_branch = payload["pull_request"]["head_branch"].tame(check_string)
    base_branch = payload["pull_request"]["base_branch"].tame(check_string)
    title = payload["pull_request"]["title"].tame(check_string) if include_title else None

    return get_pull_request_event_message(
        user_name=user_name,
        action=action,
        url=url,
        number=number,
        target_branch=target_branch,
        base_branch=base_branch,
        title=title,
    )
예제 #36
0
def get_opened_or_update_pull_request_body(helper: Helper) -> str:
    payload = helper.payload
    include_title = helper.include_title
    pull_request = payload['pull_request']
    action = payload['action']
    if action == 'synchronize':
        action = 'updated'
    assignee = None
    if pull_request.get('assignee'):
        assignee = pull_request['assignee']['login']

    return get_pull_request_event_message(
        get_sender_name(payload),
        action,
        pull_request['html_url'],
        target_branch=pull_request['head']['ref'],
        base_branch=pull_request['base']['ref'],
        message=pull_request['body'],
        assignee=assignee,
        number=pull_request['number'],
        title=pull_request['title'] if include_title else None,
    )
예제 #37
0
파일: view.py 프로젝트: quickheap/zulip
def get_pull_request_review_body(payload):
    # type: (Dict[str, Any]) -> Text
    return get_pull_request_event_message(get_sender_name(payload),
                                          'submitted',
                                          payload['review']['html_url'],
                                          type='PR Review')
예제 #38
0
def get_pull_request_action_body(payload: Dict[str, Any], action: str) -> str:
    pull_request = payload['pullrequest']
    return get_pull_request_event_message(get_user_username(payload), action,
                                          get_pull_request_url(pull_request),
                                          pull_request.get('id'))
예제 #39
0
파일: bitbucket2.py 프로젝트: zebesta/zulip
def get_pull_request_action_body(payload, action):
    # type: (Dict[str, Any], str) -> text_type
    pull_request = payload['pullrequest']
    return get_pull_request_event_message(get_user_username(payload), action,
                                          get_pull_request_url(pull_request),
                                          pull_request.get('id'))