summaryrefslogtreecommitdiffstatshomepage
path: root/scripts
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-02-12 13:33:35 +0100
committerJustin M. Keyes <justinkz@gmail.com>2026-02-12 13:46:53 +0100
commitd995142dbdd54dc18c6a588235011ae82b532747 (patch)
treedbbbc04364167ed0ca903cc3f9c69d87daeddfdb /scripts
parent8a901a52e1f0c0e5c877dd27a9d1be73b8082598 (diff)
fix(scripts): collect_typos.lua: show commit message on failure
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/collect_typos.lua33
1 files changed, 27 insertions, 6 deletions
diff --git a/scripts/collect_typos.lua b/scripts/collect_typos.lua
index e85fdc9c89..d5d3128c93 100755
--- a/scripts/collect_typos.lua
+++ b/scripts/collect_typos.lua
@@ -88,6 +88,21 @@ local function mime_decode(encoded)
return vim.trim(result.stdout)
end
+local function get_commit_msg(close_pr_lines, co_author_lines)
+ return ('docs: misc\n\n%s\n\n%s\n'):format(
+ table.concat(close_pr_lines, '\n'),
+ table.concat(co_author_lines, '\n')
+ )
+end
+
+local function get_fail_msg(msg, pr_number, close_pr_lines, co_author_lines)
+ return ('%s %s\n\nPending commit message:\n%s'):format(
+ msg,
+ pr_number or '',
+ get_commit_msg(close_pr_lines, co_author_lines)
+ )
+end
+
local function main()
local pr_list = vim.json.decode(
run_die(
@@ -107,9 +122,10 @@ local function main()
local close_pr_lines = {}
local co_author_lines = {}
for _, pr_number in ipairs(pr_numbers) do
+ print(('PR #%s'):format(pr_number))
local patch_file = run_die(
{ 'gh', 'pr', 'diff', tostring(pr_number), '--patch' },
- 'Failed to get patch of PR ' .. pr_number
+ get_fail_msg('Failed to get patch for PR', pr_number, close_pr_lines, co_author_lines)
)
-- Using --3way allows skipping changes already included in a previous commit.
-- If there are conflicts, it will fail and need manual conflict resolution.
@@ -128,15 +144,20 @@ local function main()
end
end
else
- print('Failed to apply patch of PR ' .. pr_number)
+ print(
+ get_fail_msg('Failed to apply patch for PR', pr_number, close_pr_lines, co_author_lines)
+ )
end
end
- local msg = ('docs: misc\n\n%s\n\n%s\n'):format(
- table.concat(close_pr_lines, '\n'),
- table.concat(co_author_lines, '\n')
+ local msg = get_commit_msg(close_pr_lines, co_author_lines)
+ print(
+ run_die(
+ { 'git', 'commit', '--file', '-' },
+ get_fail_msg('Failed to create commit', nil, close_pr_lines, co_author_lines),
+ msg
+ )
)
- print(run_die({ 'git', 'commit', '--file', '-' }, 'Failed to create commit', msg))
end
main()