You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by to...@apache.org on 2022/07/31 02:37:32 UTC
[lucene-jira-archive] 01/01: don't create issue links to self
This is an automated email from the ASF dual-hosted git repository.
tomoko pushed a commit to branch do-not-create-link-back-to-self
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git
commit c0a05302b0bfb0e92a6df6e1ff8da355abe1a035
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Sun Jul 31 11:37:22 2022 +0900
don't create issue links to self
---
migration/src/jira_util.py | 10 +++++-----
migration/src/remap_cross_issue_links.py | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/migration/src/jira_util.py b/migration/src/jira_util.py
index 607f44bd..c25c8ea1 100644
--- a/migration/src/jira_util.py
+++ b/migration/src/jira_util.py
@@ -289,34 +289,34 @@ def convert_text(text: str, att_replace_map: dict[str, str] = {}, account_map: d
return text
-def embed_gh_issue_link(text: str, issue_id_map: dict[str, str]) -> str:
+def embed_gh_issue_link(text: str, issue_id_map: dict[str, str], gh_number_self: int = None) -> str:
"""Embed GitHub issue number
"""
def repl_simple(m: re.Match):
res = m.group(0)
gh_number = issue_id_map.get(m.group(2))
- if gh_number:
+ if gh_number and gh_number != gh_number_self:
res = f"{m.group(1)}#{gh_number}{m.group(3)}"
return res
def repl_paren(m: re.Match):
res = m.group(0)
gh_number = issue_id_map.get(m.group(2))
- if gh_number:
+ if gh_number and gh_number != gh_number_self:
res = f"{m.group(1)}#{gh_number}{m.group(3)}"
return res
def repl_bracket(m: re.Match):
res = m.group(0)
gh_number = issue_id_map.get(m.group(2))
- if gh_number:
+ if gh_number and gh_number != gh_number_self:
res = f"#{gh_number}"
return res
def repl_md_link(m: re.Match):
res = m.group(0)
gh_number = issue_id_map.get(m.group(1))
- if gh_number:
+ if gh_number and gh_number != gh_number_self:
res = f"{m.group(0)} (#{gh_number})"
# print(res)
return res
diff --git a/migration/src/remap_cross_issue_links.py b/migration/src/remap_cross_issue_links.py
index 5d1201f9..fd4e563d 100644
--- a/migration/src/remap_cross_issue_links.py
+++ b/migration/src/remap_cross_issue_links.py
@@ -24,7 +24,7 @@ logger = logging_setup(log_dir, "remap_cross_issue_links")
def remap_issue_link_in_issue_body(issue_number: int, issue_id_map: dict[str, str], data_dir: Path, token: str, repo: str):
body = get_issue_body(token, repo, issue_number, logger)
if body:
- updated_body = embed_gh_issue_link(body, issue_id_map)
+ updated_body = embed_gh_issue_link(body, issue_id_map, issue_number)
if updated_body == body:
logger.debug(f"Issue {issue_number} does not contain any cross-issue links; nothing to do.")
return
@@ -44,7 +44,7 @@ def remap_issue_link_in_comments(issue_number: int, issue_id_map: dict[str, str]
for comment in comments:
id = comment.id
body = comment.body
- updated_body = embed_gh_issue_link(body, issue_id_map)
+ updated_body = embed_gh_issue_link(body, issue_id_map, issue_number)
if updated_body == body:
logger.debug(f"Comment {id} does not contain any cross-issue links; nothing to do.")
continue