From 3b9ceeff5b57efd94fa1a1451cbb99a3b7ab3e11 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Thu, 15 Aug 2024 15:15:47 -0500 Subject: [PATCH] [NFC] Add circt copy of upstream's linkify. (#7521) --- utils/linkify.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 utils/linkify.sh diff --git a/utils/linkify.sh b/utils/linkify.sh new file mode 100755 index 0000000000..1113552eaa --- /dev/null +++ b/utils/linkify.sh @@ -0,0 +1,26 @@ +#!/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 CIRCT checkout: +# +# git config core.pager 'utils/linkify.sh | pager' +# +# Consider: +# +# git config core.pager 'utils/linkify.sh | ${PAGER:-less}' +# +# 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 +# +# Copied from upstream LLVM's llvm/utils/git/linkify. + +sed \ + -e 's,\(#\|\bPR\)\([0-9]\+\),\x1b]8;;https://github.com/llvm/circt/issues/\2\x1b\\\0\x1b]8;;\x1b\\,gi' \ + -e 's,[0-9a-f]\{40\},\x1b]8;;https://github.com/llvm/circt/commit/\0\x1b\\\0\x1b]8;;\x1b\\,g'