From 42c467d33cdf2adecf652dcaa359e3a72e947018 Mon Sep 17 00:00:00 2001
From: Matteo Fiandesio <matteo.fiandesio@seqera.io>
Date: Mon, 18 Mar 2024 16:43:41 +0100
Subject: [PATCH 1/7] fix: adds a short sha representation to modules list
 command pointing to the repo specific commit

---
 nf_core/components/list.py      | 7 ++++---
 nf_core/modules/modules_repo.py | 8 ++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/nf_core/components/list.py b/nf_core/components/list.py
index b0c5af219f..f4407285cd 100644
--- a/nf_core/components/list.py
+++ b/nf_core/components/list.py
@@ -125,10 +125,11 @@ def pattern_msg(keywords: List[str]) -> str:
                             version_sha = component_entry["git_sha"]
                             try:
                                 # pass repo_name to get info on modules even outside nf-core/modules
-                                message, date = ModulesRepo(
+                                module = ModulesRepo(
                                     remote_url=repo_url,
                                     branch=component_entry["branch"],
-                                ).get_commit_info(version_sha)
+                                )
+                                message, date = module.get_commit_info(version_sha)
                             except LookupError as e:
                                 log.warning(e)
                                 date = "[red]Not Available"
@@ -140,7 +141,7 @@ def pattern_msg(keywords: List[str]) -> str:
                             version_sha = "[red]Not Available"
                             date = "[red]Not Available"
                             message = "[red]Not Available"
-                        table.add_row(component, repo_url, version_sha, message, date)
+                        table.add_row(component, f'[link={repo_url}]{repo_url}[/link]', f'[link={module.gitless_repo()}/commit/{version_sha}]{version_sha[:7]}[/link]', message, date)
                         components.append(component)
 
         if print_json:
diff --git a/nf_core/modules/modules_repo.py b/nf_core/modules/modules_repo.py
index 204c20fd71..7f58641aa6 100644
--- a/nf_core/modules/modules_repo.py
+++ b/nf_core/modules/modules_repo.py
@@ -69,6 +69,14 @@ def __init__(self, remote_url=None, branch=None, no_pull=False, hide_progress=Fa
 
         self.avail_module_names = None
 
+
+    def gitless_repo(self):
+        gitless_repo_url = self.remote_url
+        if(self.remote_url and '.git' in self.remote_url):
+            gitless_repo_url = gitless_repo_url[:-3]
+        return gitless_repo_url
+
+
     def setup_local_repo(self, remote, branch, hide_progress=True, in_cache=False):
         """
         Sets up the local git repository. If the repository has been cloned previously, it

From ca5b78b675b46fc474eb1f494b25fd0c288958ed Mon Sep 17 00:00:00 2001
From: Matteo Fiandesio <matteo.fiandesio@seqera.io>
Date: Mon, 18 Mar 2024 17:32:58 +0100
Subject: [PATCH 2/7] adds changelog entry

---
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5e3189edaa..3fb06f4509 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -49,6 +49,7 @@
 - Patch: handle file not found when it is an added file to a module ([#2771](https://github.com/nf-core/tools/pull/2771))
 - Handle symlinks when migrating pytest ([#2770](https://github.com/nf-core/tools/pull/2770))
 - Add `--profile` parameter to nf-test command ([#2767](https://github.com/nf-core/tools/pull/2767))
+- Reduce the size of the sha representation in the `list` command and links to the specific commit ([#2870](https://github.com/nf-core/tools/pull/2870))
 
 ### General
 

From 171914b538c1b746454bf2bac6e1e7651f8d3a37 Mon Sep 17 00:00:00 2001
From: nf-core-bot <core@nf-co.re>
Date: Mon, 18 Mar 2024 21:04:57 +0000
Subject: [PATCH 3/7] [automated] Fix code linting

---
 nf_core/components/list.py      | 8 +++++++-
 nf_core/modules/modules_repo.py | 4 +---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/nf_core/components/list.py b/nf_core/components/list.py
index f4407285cd..1606cfe74a 100644
--- a/nf_core/components/list.py
+++ b/nf_core/components/list.py
@@ -141,7 +141,13 @@ def pattern_msg(keywords: List[str]) -> str:
                             version_sha = "[red]Not Available"
                             date = "[red]Not Available"
                             message = "[red]Not Available"
-                        table.add_row(component, f'[link={repo_url}]{repo_url}[/link]', f'[link={module.gitless_repo()}/commit/{version_sha}]{version_sha[:7]}[/link]', message, date)
+                        table.add_row(
+                            component,
+                            f"[link={repo_url}]{repo_url}[/link]",
+                            f"[link={module.gitless_repo()}/commit/{version_sha}]{version_sha[:7]}[/link]",
+                            message,
+                            date,
+                        )
                         components.append(component)
 
         if print_json:
diff --git a/nf_core/modules/modules_repo.py b/nf_core/modules/modules_repo.py
index 7f58641aa6..839f2a75ee 100644
--- a/nf_core/modules/modules_repo.py
+++ b/nf_core/modules/modules_repo.py
@@ -69,14 +69,12 @@ def __init__(self, remote_url=None, branch=None, no_pull=False, hide_progress=Fa
 
         self.avail_module_names = None
 
-
     def gitless_repo(self):
         gitless_repo_url = self.remote_url
-        if(self.remote_url and '.git' in self.remote_url):
+        if self.remote_url and ".git" in self.remote_url:
             gitless_repo_url = gitless_repo_url[:-3]
         return gitless_repo_url
 
-
     def setup_local_repo(self, remote, branch, hide_progress=True, in_cache=False):
         """
         Sets up the local git repository. If the repository has been cloned previously, it

From afaf2ff826eb039a7751d7e29b90a52b6c07f4b9 Mon Sep 17 00:00:00 2001
From: Phil Ewels <phil.ewels@seqera.io>
Date: Mon, 18 Mar 2024 22:43:32 +0100
Subject: [PATCH 4/7] Hyperlink module name and file path in lint results

---
 nf_core/components/lint/__init__.py | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/nf_core/components/lint/__init__.py b/nf_core/components/lint/__init__.py
index c99934bca3..ee1bd58b15 100644
--- a/nf_core/components/lint/__init__.py
+++ b/nf_core/components/lint/__init__.py
@@ -11,6 +11,7 @@
 import rich.box
 import rich.console
 import rich.panel
+import rich.repr
 from rich.markdown import Markdown
 from rich.table import Table
 
@@ -31,6 +32,7 @@ class LintExceptionError(Exception):
     pass
 
 
+@rich.repr.auto
 class LintResult:
     """An object to hold the results of a lint test"""
 
@@ -42,6 +44,7 @@ def __init__(self, component, lint_test, message, file_path):
         self.component_name = component.component_name
 
 
+@rich.repr.auto
 class ComponentLint(ComponentCommand):
     """
     An object for linting modules and subworkflows either in a clone of the 'nf-core/modules'
@@ -231,9 +234,20 @@ def format_result(test_results, table):
                 if last_modname and lint_result.component_name != last_modname:
                     even_row = not even_row
                 last_modname = lint_result.component_name
+
+                # If this is an nf-core module, link to the nf-core webpage
+                if lint_result.component.repo_url == "https://github.com/nf-core/modules.git":
+                    module_name = f"[link=https://nf-co.re/modules/{lint_result.component_name.replace("/","_")}]{lint_result.component_name}[/link]"
+                else:
+                    module_name = lint_result.component_name
+
+                # Make the filename clickable to open in VSCode
+                file_path = os.path.relpath(lint_result.file_path, self.dir)
+                file_path_link = f"[link=vscode://file/{os.path.abspath(file_path)}]{file_path}[/link]"
+
                 table.add_row(
-                    Markdown(f"{lint_result.component_name}"),
-                    os.path.relpath(lint_result.file_path, self.dir),
+                    module_name,
+                    file_path_link,
                     Markdown(f"{lint_result.message}"),
                     style="dim" if even_row else None,
                 )

From fba35785979eb713480f81446fff231ab142d104 Mon Sep 17 00:00:00 2001
From: Phil Ewels <phil.ewels@seqera.io>
Date: Mon, 18 Mar 2024 22:51:06 +0100
Subject: [PATCH 5/7] Fix link and shorten GitHub repo name in nf-core modules
 list local

---
 nf_core/components/list.py      | 5 +++--
 nf_core/modules/modules_repo.py | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/nf_core/components/list.py b/nf_core/components/list.py
index 1606cfe74a..f5f2744e17 100644
--- a/nf_core/components/list.py
+++ b/nf_core/components/list.py
@@ -70,7 +70,7 @@ def pattern_msg(keywords: List[str]) -> str:
         # We have a pipeline - list what's installed
         else:
             # Check that we are in a pipeline directory
-            print(f"{self.repo_type=}")
+            log.info(f"Repository type: [blue]{self.repo_type}")
             try:
                 if self.repo_type != "pipeline":
                     raise UserWarning(
@@ -141,9 +141,10 @@ def pattern_msg(keywords: List[str]) -> str:
                             version_sha = "[red]Not Available"
                             date = "[red]Not Available"
                             message = "[red]Not Available"
+                        nice_repo_name = repo_url.replace("https://github.com/", "").replace(".git", "")
                         table.add_row(
                             component,
-                            f"[link={repo_url}]{repo_url}[/link]",
+                            f"[link={repo_url}]{nice_repo_name}[/link]",
                             f"[link={module.gitless_repo()}/commit/{version_sha}]{version_sha[:7]}[/link]",
                             message,
                             date,
diff --git a/nf_core/modules/modules_repo.py b/nf_core/modules/modules_repo.py
index 839f2a75ee..9694920274 100644
--- a/nf_core/modules/modules_repo.py
+++ b/nf_core/modules/modules_repo.py
@@ -72,7 +72,7 @@ def __init__(self, remote_url=None, branch=None, no_pull=False, hide_progress=Fa
     def gitless_repo(self):
         gitless_repo_url = self.remote_url
         if self.remote_url and ".git" in self.remote_url:
-            gitless_repo_url = gitless_repo_url[:-3]
+            gitless_repo_url = gitless_repo_url[:-4]
         return gitless_repo_url
 
     def setup_local_repo(self, remote, branch, hide_progress=True, in_cache=False):

From 554d5d719b5851a017b38e601ab7039625d04fce Mon Sep 17 00:00:00 2001
From: Phil Ewels <phil.ewels@seqera.io>
Date: Mon, 18 Mar 2024 22:52:50 +0100
Subject: [PATCH 6/7] extend changelog

---
 CHANGELOG.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index e51597e89c..1e84fc8043 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -79,7 +79,8 @@
 - Patch: handle file not found when it is an added file to a module ([#2771](https://github.com/nf-core/tools/pull/2771))
 - Handle symlinks when migrating pytest ([#2770](https://github.com/nf-core/tools/pull/2770))
 - Add `--profile` parameter to nf-test command ([#2767](https://github.com/nf-core/tools/pull/2767))
-- Reduce the size of the sha representation in the `list` command and links to the specific commit ([#2870](https://github.com/nf-core/tools/pull/2870))
+- Reduce the sha length in the `nf-core modules list local` and add links to the specific commit ([#2870](https://github.com/nf-core/tools/pull/2870))
+- Add links the nf-core module page and to open the local file in VSCode for module lint results ([#2870](https://github.com/nf-core/tools/pull/2870))
 
 ### General
 

From 54afd8d54c8523715dd3e9475574407a903f46d1 Mon Sep 17 00:00:00 2001
From: Phil Ewels <phil.ewels@seqera.io>
Date: Mon, 18 Mar 2024 23:00:50 +0100
Subject: [PATCH 7/7] Try to fix linting

---
 nf_core/components/lint/__init__.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/nf_core/components/lint/__init__.py b/nf_core/components/lint/__init__.py
index ee1bd58b15..564dcfaf6b 100644
--- a/nf_core/components/lint/__init__.py
+++ b/nf_core/components/lint/__init__.py
@@ -237,7 +237,8 @@ def format_result(test_results, table):
 
                 # If this is an nf-core module, link to the nf-core webpage
                 if lint_result.component.repo_url == "https://github.com/nf-core/modules.git":
-                    module_name = f"[link=https://nf-co.re/modules/{lint_result.component_name.replace("/","_")}]{lint_result.component_name}[/link]"
+                    module_url = "https://nf-co.re/modules/" + lint_result.component_name.replace("/", "_")
+                    module_name = f"[link={module_url}]{lint_result.component_name}[/link]"
                 else:
                     module_name = lint_result.component_name