[llvm] utils/git: Add linkify script. (PR #103496)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 18:56:17 PDT 2024


https://github.com/pcc created https://github.com/llvm/llvm-project/pull/103496

This script linkifies (i.e. makes clickable in the terminal) text that appears
to be a pull request or issue reference (e.g. #12345 or PR12345) or a
40-character commit hash (e.g. abc123). You can configure git to automatically
send the output of commands that pipe their output through a pager, such as
`git log` and `git show`, through this script by running this command from
within your LLVM checkout:

git config core.pager 'llvm/utils/git/linkify | pager'

The pager command is run from the root of the repository even if the git
command is run from a subdirectory, so the relative path should always work.

It requires OSC 8 support in the terminal. For a list of compatible terminals,
see https://github.com/Alhadis/OSC8-Adoption


>From 0eaad6983285f75a61fa5b6cecc9eacab573a71c Mon Sep 17 00:00:00 2001
From: Peter Collingbourne <peter at pcc.me.uk>
Date: Tue, 13 Aug 2024 18:56:02 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 llvm/utils/git/linkify | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100755 llvm/utils/git/linkify

diff --git a/llvm/utils/git/linkify b/llvm/utils/git/linkify
new file mode 100755
index 00000000000000..9fcadd758492cf
--- /dev/null
+++ b/llvm/utils/git/linkify
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# This script linkifies (i.e. makes clickable in the terminal) text that appears
+# to be a pull request or issue reference (e.g. #12345 or PR12345) or a
+# 40-character commit hash (e.g. abc123). You can configure git to automatically
+# send the output of commands that pipe their output through a pager, such as
+# `git log` and `git show`, through this script by running this command from
+# within your LLVM checkout:
+#
+# git config core.pager 'llvm/utils/git/linkify | pager'
+#
+# The pager command is run from the root of the repository even if the git
+# command is run from a subdirectory, so the relative path should always work.
+#
+# It requires OSC 8 support in the terminal. For a list of compatible terminals,
+# see https://github.com/Alhadis/OSC8-Adoption
+
+sed \
+  -e 's,\(#\|\bPR\)\([0-9]\+\),\x1b]8;;https://github.com/llvm/llvm-project/issues/\2\x1b\\\0\x1b]8;;\x1b\\,gi' \
+  -e 's,[0-9a-f]\{40\},\x1b]8;;https://github.com/llvm/llvm-project/commit/\0\x1b\\\0\x1b]8;;\x1b\\,g'



More information about the llvm-commits mailing list