Esempio n. 1
0
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}
Esempio n. 2
0
def format_new_branch_event(payload: Dict[str, Any]) -> str:

    branch_name = payload['ref']
    url = '{}/src/{}'.format(payload['repository']['html_url'], branch_name)

    data = {
        'user_name': payload['sender']['username'],
        'url': url,
        'branch_name': branch_name
    }
    return get_create_branch_event_message(**data)
Esempio n. 3
0
def format_new_branch_event(payload: Dict[str, Any]) -> Text:

    branch_name = payload['ref']
    url = '{}/src/{}'.format(payload['repository']['html_url'], branch_name)

    data = {
        'user_name': payload['sender']['username'],
        'url': url,
        'branch_name': branch_name
    }
    return get_create_branch_event_message(**data)
Esempio n. 4
0
def format_new_branch_event(payload: Dict[str, Any]) -> str:

    branch_name = payload["ref"]
    url = "{}/src/{}".format(payload["repository"]["html_url"], branch_name)

    data = {
        "user_name": payload["sender"]["username"],
        "url": url,
        "branch_name": branch_name,
    }
    return get_create_branch_event_message(**data)
Esempio n. 5
0
def format_new_branch_event(payload: WildValue) -> str:

    branch_name = payload["ref"].tame(check_string)
    url = "{}/src/{}".format(payload["repository"]["html_url"].tame(check_string), branch_name)

    data = {
        "user_name": payload["sender"]["username"].tame(check_string),
        "url": url,
        "branch_name": branch_name,
    }
    return get_create_branch_event_message(**data)