Rename consts in lib/webhooks/git.py to make it more general.

Rename:
   PUSH_COMMITS_LIMIT to COMMITS_LIMIT
   PUSH_COMMIT_ROW_TEMPLATE to COMMIT_ROW_TEMPLATE
   PUSH_COMMITS_MORE_THAN_LIMIT_TEMPLATE to COMMITS_MORE_THAN_LIMIT_TEMPLATE
This commit is contained in:
Tomasz Kolek
2016-10-12 23:27:24 +02:00
committed by Tim Abbott
parent ee70cc5141
commit d2cedd3667
5 changed files with 21 additions and 20 deletions

View File

@@ -6,11 +6,12 @@ SUBJECT_WITH_PR_INFO_TEMPLATE = u'{repo} / {type} #{id} {title}'
EMPTY_SHA = '0000000000000000000000000000000000000000'
PUSH_COMMITS_LIMIT = 10
COMMITS_LIMIT = 10
COMMIT_ROW_TEMPLATE = u'* [{commit_short_sha}]({commit_url}): {commit_msg}\n'
COMMITS_MORE_THAN_LIMIT_TEMPLATE = u"[and {commits_number} more commit(s)]"
PUSH_PUSHED_TEXT_WITH_URL = u"[pushed]({compare_url})"
PUSH_PUSHED_TEXT_WITHOUT_URL = u"pushed"
PUSH_COMMIT_ROW_TEMPLATE = u'* [{commit_short_sha}]({commit_url}): {commit_msg}\n'
PUSH_COMMITS_MORE_THAN_LIMIT_TEMPLATE = u"[and {commits_number} more commit(s)]"
PUSH_COMMITS_MESSAGE_TEMPLATE = u"""{user_name} {pushed_text} to branch {branch_name}
{commits_list}
@@ -28,16 +29,16 @@ PULL_REQUEST_CONTENT_MESSAGE_TEMPLATE = u"\n~~~ quote\n{message}\n~~~"
def get_push_commits_event_message(user_name, compare_url, branch_name, commits_data):
# type: (text_type, Optional[text_type], text_type, List[Dict[str, Any]]) -> text_type
commits_list_message = u''
for commit in commits_data[:PUSH_COMMITS_LIMIT]:
commits_list_message += PUSH_COMMIT_ROW_TEMPLATE.format(
for commit in commits_data[:COMMITS_LIMIT]:
commits_list_message += COMMIT_ROW_TEMPLATE.format(
commit_short_sha=commit.get('sha')[:7],
commit_url=commit.get('url'),
commit_msg=commit.get('message').partition('\n')[0]
)
if len(commits_data) > PUSH_COMMITS_LIMIT:
commits_more_than_limit_message = PUSH_COMMITS_MORE_THAN_LIMIT_TEMPLATE.format(
commits_number=len(commits_data) - PUSH_COMMITS_LIMIT)
if len(commits_data) > COMMITS_LIMIT:
commits_more_than_limit_message = COMMITS_MORE_THAN_LIMIT_TEMPLATE.format(
commits_number=len(commits_data) - COMMITS_LIMIT)
else:
commits_more_than_limit_message = ''