From 865cc60288281b16c460a036673efef25edac715 Mon Sep 17 00:00:00 2001 From: amtoine Date: Sun, 5 Nov 2023 18:20:20 +0100 Subject: [PATCH 1/2] add `update-ignored-revisions` to `toolkit.nu` --- toolkit.nu | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/toolkit.nu b/toolkit.nu index 56a94611..5abbbb18 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -13,3 +13,32 @@ export def "test" [ nupm test } } + +# pull down the list of `refactor` PRs that have been merged and ignore the revisions +# +# > inspired by [*How to exclude commits from git blame*](https://www.stefanjudis.com/today-i-learned/how-to-exclude-commits-from-git-blame/) +export def "update-ignored-revisions" [] { + const FILE = ".git-blame-ignore-revs" + + let commits = ^gh -R amtoine/nu-git-manager pr list [ + --state merged + --label refactor + --json "number,title,mergeCommit,url" + ] + | from json + | select number title mergeCommit.oid url + | rename --column {mergeCommit_oid: "commit"} + | reverse + | each { $"# ($in.title): [#($in.number)]\(($in.url)\)\n($in.commit)" } + | str join "\n\n" + + [ + "# Run this command to always ignore formatting commits in `git blame`", + "# ```", + $"# git config --global blame.ignoreRevsFile ($FILE)", + "# ```", + $commits + ] | str join "\n" | save --force $FILE + + print $"ignored revisions stored in `($FILE)`" +} From 04d7c5d276354d070ea640480de177bddb7016c8 Mon Sep 17 00:00:00 2001 From: amtoine Date: Sun, 5 Nov 2023 18:32:54 +0100 Subject: [PATCH 2/2] do not tell to run the config globally this will break in repos that do not have such a file... --- toolkit.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit.nu b/toolkit.nu index 5abbbb18..4c8c3bb3 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -35,7 +35,7 @@ export def "update-ignored-revisions" [] { [ "# Run this command to always ignore formatting commits in `git blame`", "# ```", - $"# git config --global blame.ignoreRevsFile ($FILE)", + $"# git config blame.ignoreRevsFile ($FILE)", "# ```", $commits ] | str join "\n" | save --force $FILE