mirror of https://github.com/zulip/zulip.git
Add is_truncated param to git integrations push commits event.
Add is_truncated param for cases when we know that there were more commits but we dont know actual number and want just inform about existing of the rest.
This commit is contained in:
parent
81f18b829d
commit
ed1d7f7997
|
@ -32,8 +32,8 @@ PUSH_TAGS_MESSAGE_TEMPLATE = u"""{user_name} {action} {tag} tag"""
|
||||||
TAG_WITH_URL_TEMPLATE = u"[{tag_name}]({tag_url})"
|
TAG_WITH_URL_TEMPLATE = u"[{tag_name}]({tag_url})"
|
||||||
TAG_WITHOUT_URL_TEMPLATE = u"{tag_name}"
|
TAG_WITHOUT_URL_TEMPLATE = u"{tag_name}"
|
||||||
|
|
||||||
def get_push_commits_event_message(user_name, compare_url, branch_name, commits_data):
|
def get_push_commits_event_message(user_name, compare_url, branch_name, commits_data, is_truncated=False):
|
||||||
# type: (text_type, Optional[text_type], text_type, List[Dict[str, Any]]) -> text_type
|
# type: (text_type, Optional[text_type], text_type, List[Dict[str, Any]], Optional[bool]) -> text_type
|
||||||
if compare_url:
|
if compare_url:
|
||||||
pushed_text_message = PUSH_PUSHED_TEXT_WITH_URL.format(compare_url=compare_url)
|
pushed_text_message = PUSH_PUSHED_TEXT_WITH_URL.format(compare_url=compare_url)
|
||||||
else:
|
else:
|
||||||
|
@ -43,7 +43,7 @@ def get_push_commits_event_message(user_name, compare_url, branch_name, commits_
|
||||||
user_name=user_name,
|
user_name=user_name,
|
||||||
pushed_text=pushed_text_message,
|
pushed_text=pushed_text_message,
|
||||||
branch_name=branch_name,
|
branch_name=branch_name,
|
||||||
commits_data=get_commits_content(commits_data),
|
commits_data=get_commits_content(commits_data, is_truncated),
|
||||||
).rstrip()
|
).rstrip()
|
||||||
|
|
||||||
def get_force_push_commits_event_message(user_name, url, branch_name, head):
|
def get_force_push_commits_event_message(user_name, url, branch_name, head):
|
||||||
|
@ -125,8 +125,8 @@ def get_commits_comment_action_message(user_name, action, commit_url, sha, messa
|
||||||
)
|
)
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def get_commits_content(commits_data):
|
def get_commits_content(commits_data, is_truncated=False):
|
||||||
# type: (List[Dict[str, Any]]) -> text_type
|
# type: (List[Dict[str, Any]], Optional[bool]) -> text_type
|
||||||
commits_content = u''
|
commits_content = u''
|
||||||
for commit in commits_data[:COMMITS_LIMIT]:
|
for commit in commits_data[:COMMITS_LIMIT]:
|
||||||
commits_content += COMMIT_ROW_TEMPLATE.format(
|
commits_content += COMMIT_ROW_TEMPLATE.format(
|
||||||
|
@ -137,7 +137,12 @@ def get_commits_content(commits_data):
|
||||||
|
|
||||||
if len(commits_data) > COMMITS_LIMIT:
|
if len(commits_data) > COMMITS_LIMIT:
|
||||||
commits_content += COMMITS_MORE_THAN_LIMIT_TEMPLATE.format(
|
commits_content += COMMITS_MORE_THAN_LIMIT_TEMPLATE.format(
|
||||||
commits_number=len(commits_data) - COMMITS_LIMIT)
|
commits_number=len(commits_data) - COMMITS_LIMIT
|
||||||
|
)
|
||||||
|
elif is_truncated:
|
||||||
|
commits_content += COMMITS_MORE_THAN_LIMIT_TEMPLATE.format(
|
||||||
|
commits_number=''
|
||||||
|
).replace(' ', ' ')
|
||||||
return commits_content.rstrip()
|
return commits_content.rstrip()
|
||||||
|
|
||||||
def get_short_sha(sha):
|
def get_short_sha(sha):
|
||||||
|
|
Loading…
Reference in New Issue