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/21 11:40:52 UTC

[lucene-jira-archive] branch hyperlink-commitbot-comment created (now 80eb1b75)

This is an automated email from the ASF dual-hosted git repository.

tomoko pushed a change to branch hyperlink-commitbot-comment
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git


      at 80eb1b75 enable hyperlinks to a commit in commitbots' comments

This branch includes the following new commits:

     new 80eb1b75 enable hyperlinks to a commit in commitbots' comments

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[lucene-jira-archive] 01/01: enable hyperlinks to a commit in commitbots' comments

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomoko pushed a commit to branch hyperlink-commitbot-comment
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git

commit 80eb1b7551a52a9d67d779e366003bb47387335e
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Thu Jul 21 20:40:39 2022 +0900

    enable hyperlinks to a commit in commitbots' comments
---
 migration/src/jira2github_import.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/migration/src/jira2github_import.py b/migration/src/jira2github_import.py
index 7edd88da..67cfdb4f 100644
--- a/migration/src/jira2github_import.py
+++ b/migration/src/jira2github_import.py
@@ -123,6 +123,17 @@ def convert_issue(num: int, dump_dir: Path, output_dir: Path, account_map: dict[
             author_gh = account_map.get(author_name)
             return f"{author_dispname} (@{author_gh})" if author_gh else author_dispname
         
+        def enable_hyperlink_to_commit(comment_body: str):
+            lines = []
+            for line in comment_body.split("\n"):
+                # remove '[' and ']' iff it contains a URL (i.e. link to a commit in ASF GitBox repo).
+                m = re.match(r"\[\s?(https?://\S+)\s?\]", line.strip())
+                if m:
+                    lines.append(m.group(1))
+                else:
+                    lines.append(line)
+            return "\n".join(lines)
+
         comments = extract_comments(o)
         comments_data = []
         for (comment_author_name, comment_author_dispname, comment_body, comment_created, comment_updated, comment_id) in comments:
@@ -135,6 +146,10 @@ def convert_issue(num: int, dump_dir: Path, output_dir: Path, account_map: dict[
                 comment_time += f' [updated: {comment_updated_datetime.strftime("%b %d %Y")}]'
             try:
                 comment_body = f'{convert_text(comment_body, att_replace_map, account_map)}\n\n'
+                # apply a special conversion for jira-bot's comments.
+                # see https://github.com/apache/lucene-jira-archive/issues/54
+                if comment_author_name == "jira-bot":
+                    comment_body = enable_hyperlink_to_commit(comment_body)
             except Exception as e:
                 logger.error(traceback.format_exc(limit=100))
                 logger.error(f"Failed to convert comment on {jira_issue_id(num)} due to above exception ({str(e)}); falling back to original Jira comment as code block.")