@@ -526,6 +526,28 @@ class CmdRun extends CmdBase implements HubOptions {
526526 return " \0 33]8;;${ url} \0 07${ text} \0 33]8;;\0 07"
527527 }
528528
529+ /**
530+ * Formats the revision string with an optional hyperlink on the commit hash.
531+ * If commitUrl is available, the commit hash portion is hyperlinked and the
532+ * branch/tag name (e.g., " [master]") is appended as plain text.
533+ *
534+ * @param revision The full revision string (e.g., "2ce0b0e294 [master]")
535+ * @param commitId The full commit SHA
536+ * @param commitUrl The URL to link to, or null to skip hyperlinking
537+ * @return The formatted revision string
538+ */
539+ protected static String formatRevision (String revision , String commitId , String commitUrl ) {
540+ if ( ! commitUrl || ! commitId )
541+ return revision ?: ' '
542+ final shortCommit = commitId. substring(0 , Math . min(10 , commitId. length()))
543+ final linkedCommit = hyperlink(shortCommit, commitUrl)
544+ // Append the branch/tag name if revision contains more than just the commit
545+ if ( revision && revision != shortCommit && revision. startsWith(shortCommit) ) {
546+ return linkedCommit + revision. substring(shortCommit. length())
547+ }
548+ return linkedCommit
549+ }
550+
529551 static void detectModuleBinaryFeature (ConfigMap config ) {
530552 final moduleBinaries = config. navigate(' nextflow.enable.moduleBinaries' , false )
531553 if ( moduleBinaries ) {
@@ -555,18 +577,7 @@ class CmdRun extends CmdBase implements HubOptions {
555577 fmt. bold(). fg(Color . CYAN ). a(runName). reset()
556578 fmt. a(Attribute . INTENSITY_FAINT ). a(" ] " ). reset()
557579 fmt. fg(Color . CYAN ). a(" revision: " ). reset()
558- // Make commit hash a hyperlink if commit URL is available
559- if ( commitUrl && commitId ) {
560- final shortCommit = commitId. substring(0 , Math . min(10 , commitId. length()))
561- fmt. fg(Color . CYAN ). a(hyperlink(shortCommit, commitUrl)). reset()
562- // Append the branch/tag name if revision contains more than just the commit
563- if ( revision && revision != shortCommit && revision. startsWith(shortCommit) ) {
564- fmt. fg(Color . CYAN ). a(revision. substring(shortCommit. length())). reset()
565- }
566- }
567- else {
568- fmt. fg(Color . CYAN ). a(revision). reset()
569- }
580+ fmt. fg(Color . CYAN ). a(formatRevision(revision, commitId, commitUrl)). reset()
570581 fmt. a(" \n " )
571582 AnsiConsole . out(). println (fmt. eraseLine())
572583 }
0 commit comments