Skip to content

Commit

Permalink
adds a whitespace after github URLs and user mentions to ensure that …
Browse files Browse the repository at this point in the history
…the link is correctly interpreted independently of the context in which it occurs
  • Loading branch information
ArquintL committed Feb 18, 2020
1 parent 49a5a39 commit 1d3626b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions migrate-discussions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def replace_issue_link(match):
# leave link unchanged:
return match.group(0)
grepo = config.KNOWN_REPO_MAPPING[brepo]
return r'https://github.com/{repo}/issues/{issue_nr}'.format(
return r'https://github.com/{repo}/issues/{issue_nr} '.format(
repo=grepo, issue_nr=issue_nr)
return EXPLICIT_ISSUE_LINK_RE.sub(replace_issue_link, body)

Expand All @@ -48,7 +48,7 @@ def replace_issue_link(match):
if grepo is None:
# interpret as same repo link
grepo = args.github_repository
return r'https://github.com/{repo}/issues/{issue_nr}'.format(
return r'https://github.com/{repo}/issues/{issue_nr} '.format(
repo=grepo, issue_nr=issue_nr)
return IMPLICIT_ISSUE_LINK_RE.sub(replace_issue_link, body)

Expand All @@ -69,7 +69,7 @@ def replace_pr_link(match):
grepo = config.KNOWN_REPO_MAPPING[brepo]
issues_count = config.KNOWN_ISSUES_COUNT_MAPPING[brepo]
gpr_number = bpr_nr + issues_count
return r'https://github.com/{repo}/pull/{gpr_number}'.format(
return r'https://github.com/{repo}/pull/{gpr_number} '.format(
repo=grepo, gpr_number=gpr_number)
return EXPLICIT_PR_LINK_RE.sub(replace_pr_link, body)

Expand Down Expand Up @@ -104,7 +104,7 @@ def replace_pr_link(match):
return match.group(0)
issues_count = config.KNOWN_ISSUES_COUNT_MAPPING[brepo]
gpr_number = int(bpr_nr) + issues_count
return r'https://github.com/{repo}/pull/{gpr_number}'.format(
return r'https://github.com/{repo}/pull/{gpr_number} '.format(
repo=grepo, gpr_number=gpr_number)
return IMPLICIT_PR_LINK_RE.sub(replace_pr_link, body)

Expand All @@ -118,7 +118,7 @@ def replace_user(match):
if guser is None:
# leave username unchanged, but remove the @:
return buser
return '@' + guser
return '@' + guser + ' '
return MENTION_RE.sub(replace_user, body)


Expand All @@ -134,7 +134,7 @@ def replace_commit_hash(match):
# leave link unchanged:
return match.group(0)
grepo = config.KNOWN_REPO_MAPPING[brepo]
return r'https://github.com/{grepo}/commit/{git_hash}'.format(
return r'https://github.com/{grepo}/commit/{git_hash} '.format(
grepo=grepo, git_hash=git_hash)
return EXPLICIT_COMMIT_HASH_RE.sub(replace_commit_hash, body)

Expand All @@ -156,7 +156,7 @@ def replace_commit_hash(match):
# leave unchanged:
return match.group(0)
grepo = config.KNOWN_REPO_MAPPING[brepo]
return r'https://github.com/{grepo}/commit/{git_hash}'.format(
return r'https://github.com/{grepo}/commit/{git_hash} '.format(
grepo=grepo, git_hash=git_hash)
return IMPLICIT_COMMIT_HASH_RE.sub(replace_commit_hash, body)

Expand Down

0 comments on commit 1d3626b

Please sign in to comment.