当前位置: 首页>>代码示例>>Python>>正文


Python git.get_push_commits_event_message函数代码示例

本文整理汇总了Python中zerver.lib.webhooks.git.get_push_commits_event_message函数的典型用法代码示例。如果您正苦于以下问题:Python get_push_commits_event_message函数的具体用法?Python get_push_commits_event_message怎么用?Python get_push_commits_event_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_push_commits_event_message函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: api_bitbucket_webhook

def api_bitbucket_webhook(request: HttpRequest, user_profile: UserProfile,
                          payload: Mapping[str, Any]=REQ(validator=check_dict([])),
                          branches: Optional[str]=REQ(default=None)) -> HttpResponse:
    repository = payload['repository']

    commits = [
        {
            'name': payload.get('user'),
            'sha': commit.get('raw_node'),
            'message': commit.get('message'),
            'url': u'{}{}commits/{}'.format(
                payload.get('canon_url'),
                repository.get('absolute_url'),
                commit.get('raw_node'))
        }
        for commit in payload['commits']
    ]

    if len(commits) == 0:
        # Bitbucket doesn't give us enough information to really give
        # a useful message :/
        subject = repository['name']
        content = (u"%s [force pushed](%s)"
                   % (payload['user'],
                      payload['canon_url'] + repository['absolute_url']))
    else:
        branch = payload['commits'][-1]['branch']
        if branches is not None and branches.find(branch) == -1:
            return json_success()
        content = get_push_commits_event_message(payload['user'], None, branch, commits)
        subject = SUBJECT_WITH_BRANCH_TEMPLATE.format(repo=repository['name'], branch=branch)

    check_send_webhook_message(request, user_profile, subject, content)
    return json_success()
开发者ID:284928489,项目名称:zulip,代码行数:34,代码来源:view.py

示例2: api_bitbucket_webhook

def api_bitbucket_webhook(request, user_profile, payload=REQ(validator=check_dict([])),
                          stream=REQ(default='commits')):
    # type: (HttpRequest, UserProfile, Mapping[Text, Any], Text) -> HttpResponse
    repository = payload['repository']

    commits = [
        {
            'sha': commit.get('raw_node'),
            'message': commit.get('message'),
            'url': u'{}{}commits/{}'.format(
                payload.get('canon_url'),
                repository.get('absolute_url'),
                commit.get('raw_node'))
        }
        for commit in payload.get('commits')
    ]

    if len(commits) == 0:
        # Bitbucket doesn't give us enough information to really give
        # a useful message :/
        subject = repository['name']
        content = (u"%s [force pushed](%s)"
                   % (payload['user'],
                      payload['canon_url'] + repository['absolute_url']))
    else:
        branch = payload['commits'][-1]['branch']
        content = get_push_commits_event_message(payload.get('user'), None, branch, commits)
        subject = SUBJECT_WITH_BRANCH_TEMPLATE.format(repo=repository['name'], branch=branch)

    check_send_message(user_profile, get_client("ZulipBitBucketWebhook"), "stream",
                       [stream], subject, content)
    return json_success()
开发者ID:TomaszKolek,项目名称:zulip,代码行数:32,代码来源:view.py

示例3: get_push_commits_body

def get_push_commits_body(payload):
    # type: (Dict[str, Any]) -> Text
    commits_data = [{
        'sha': commit['id'],
        'url': commit['url'],
        'message': commit['message']
    } for commit in payload['commits']]
    return get_push_commits_event_message(
        get_sender_name(payload),
        payload['compare'],
        get_branch_name_from_ref(payload['ref']),
        commits_data
    )
开发者ID:souravbadami,项目名称:zulip,代码行数:13,代码来源:view.py

示例4: get_normal_push_body

def get_normal_push_body(payload, change):
    # type: (Dict[str, Any], Dict[str, Any]) -> text_type
    commits_data = [{
        'sha': commit.get('hash'),
        'url': commit.get('links').get('html').get('href'),
        'message': commit.get('message'),
    } for commit in change['commits']]

    return get_push_commits_event_message(
        get_user_username(payload),
        change['links']['html']['href'],
        change['new']['name'],
        commits_data
    )
开发者ID:timabbott,项目名称:zulip,代码行数:14,代码来源:bitbucket2.py

示例5: format_push_event

def format_push_event(payload):
    # type: (Dict[str, Any]) -> Text

    for commit in payload['commits']:
        commit['sha'] = commit['id']

    data = {
        'user_name': payload['sender']['username'],
        'compare_url': payload['compare_url'],
        'branch_name': payload['ref'].replace('refs/heads/', ''),
        'commits_data': payload['commits']
    }

    return get_push_commits_event_message(**data)
开发者ID:aakash-cr7,项目名称:zulip,代码行数:14,代码来源:view.py

示例6: build_message_from_gitlog

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
开发者ID:galexrt,项目名称:zulip,代码行数:15,代码来源:github.py

示例7: format_push_event

def format_push_event(payload: Dict[str, Any]) -> Text:

    for commit in payload['commits']:
        commit['sha'] = commit['id']
        commit['name'] = (commit['author']['username'] or
                          commit['author']['name'].split()[0])

    data = {
        'user_name': payload['sender']['username'],
        'compare_url': payload['compare_url'],
        'branch_name': payload['ref'].replace('refs/heads/', ''),
        'commits_data': payload['commits']
    }

    return get_push_commits_event_message(**data)
开发者ID:joydeep1701,项目名称:zulip,代码行数:15,代码来源:view.py

示例8: get_push_commits_body

def get_push_commits_body(payload: Dict[str, Any]) -> Text:
    commits_data = [{
        'name': (commit.get('author').get('username') or
                 commit.get('author').get('name')),
        'sha': commit['id'],
        'url': commit['url'],
        'message': commit['message']
    } for commit in payload['commits']]
    return get_push_commits_event_message(
        get_sender_name(payload),
        payload['compare'],
        get_branch_name_from_ref(payload['ref']),
        commits_data,
        deleted=payload['deleted']
    )
开发者ID:gnprice,项目名称:zulip,代码行数:15,代码来源:view.py

示例9: get_normal_push_body

def get_normal_push_body(payload: Dict[str, Any], change: Dict[str, Any]) -> Text:
    commits_data = [{
        'name': get_commit_author_name(commit),
        'sha': commit.get('hash'),
        'url': commit.get('links').get('html').get('href'),
        'message': commit.get('message'),
    } for commit in change['commits']]

    return get_push_commits_event_message(
        get_user_username(payload),
        change['links']['html']['href'],
        change['new']['name'],
        commits_data,
        is_truncated=change['truncated']
    )
开发者ID:joydeep1701,项目名称:zulip,代码行数:15,代码来源:view.py

示例10: build_message_from_gitlog

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
开发者ID:gnprice,项目名称:zulip,代码行数:18,代码来源:view.py

示例11: get_normal_push_event_body

def get_normal_push_event_body(payload):
    # type: (Dict[str, Any]) -> text_type
    compare_url = u'{}/compare/{}...{}'.format(
        get_repository_homepage(payload),
        payload['before'],
        payload['after']
    )

    commits = [
        {
            'sha': commit.get('id'),
            'message': commit.get('message'),
            'url': commit.get('url')
        }
        for commit in payload.get('commits')
    ]

    return get_push_commits_event_message(
        get_user_name(payload),
        compare_url,
        get_branch_name(payload),
        commits
    )
开发者ID:galexrt,项目名称:zulip,代码行数:23,代码来源:gitlab.py

示例12: build_message_from_gitlog

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
开发者ID:akashnimare,项目名称:zulip,代码行数:24,代码来源:view.py


注:本文中的zerver.lib.webhooks.git.get_push_commits_event_message函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。