diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/bump-deps.sh | 104 | ||||
| -rwxr-xr-x[-rw-r--r--] | scripts/bump_deps.lua | 601 | ||||
| -rwxr-xr-x | scripts/check-includes.py | 64 | ||||
| -rw-r--r-- | scripts/cliff.toml | 73 | ||||
| -rwxr-xr-x | scripts/download-unicode-files.sh | 19 | ||||
| -rw-r--r-- | scripts/gen_help_html.lua | 1110 | ||||
| -rw-r--r-- | scripts/gen_help_html.py | 389 | ||||
| -rwxr-xr-x | scripts/gen_vimdoc.py | 94 | ||||
| -rwxr-xr-x | scripts/genappimage.sh | 12 | ||||
| -rw-r--r-- | scripts/genvimvim.lua | 6 | ||||
| -rwxr-xr-x | scripts/git-log-pretty-since.sh | 14 | ||||
| -rw-r--r-- | scripts/lintcommit.lua | 21 | ||||
| -rw-r--r-- | scripts/lua2dox.lua | 372 | ||||
| -rwxr-xr-x | scripts/lua2dox_filter | 88 | ||||
| -rwxr-xr-x | scripts/pvscheck.sh | 2 | ||||
| -rwxr-xr-x | scripts/release.sh | 4 | ||||
| -rwxr-xr-x | scripts/update_terminfo.sh | 2 | ||||
| -rwxr-xr-x | scripts/vim-patch.sh | 68 | ||||
| -rwxr-xr-x | scripts/vimpatch.lua | 7 |
19 files changed, 1860 insertions, 1190 deletions
diff --git a/scripts/bump-deps.sh b/scripts/bump-deps.sh deleted file mode 100755 index 85c7f72700..0000000000 --- a/scripts/bump-deps.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env bash -set -e -set -u -# Use privileged mode, which e.g. skips using CDPATH. -set -p - -# Ensure that the user has a bash that supports -A -if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then - echo >&2 "error: script requires bash 4+ (you have ${BASH_VERSION})." - exit 1 -fi - -readonly NVIM_SOURCE_DIR="${NVIM_SOURCE_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}" -readonly VIM_SOURCE_DIR_DEFAULT="${NVIM_SOURCE_DIR}/.vim-src" -readonly VIM_SOURCE_DIR="${VIM_SOURCE_DIR:-${VIM_SOURCE_DIR_DEFAULT}}" -BASENAME="$(basename "${0}")" -readonly BASENAME - -usage() { - echo "Bump Neovim dependencies" - echo - echo "Usage: ${BASENAME} [ -h | --pr | --branch=<dep> | --dep=<dependency> ]" - echo - echo "Options:" - echo " -h show this message and exit." - echo " --pr submit pr for bumping deps." - echo " --branch=<dep> create a branch bump-<dep> from current branch." - echo " --dep=<dependency> bump to a specific release or tag." - echo - echo "Dependency Options:" - echo " --version=<tag> bump to a specific release or tag." - echo " --commit=<hash> bump to a specific commit." - echo " --HEAD bump to a current head." - echo - echo " <dependency> is one of:" - echo " \"LuaJIT\", \"libuv\", \"Luv\", \"tree-sitter\"" -} - -# Checks if a program is in the user's PATH, and is executable. -check_executable() { - test -x "$(command -v "${1}")" -} - -require_executable() { - if ! check_executable "${1}"; then - echo >&2 "${BASENAME}: '${1}' not found in PATH or not executable." - exit 1 - fi -} - -require_executable "nvim" - -if [ $# -eq 0 ]; then - usage - exit 1 -fi - -PARSED_ARGS=$(getopt -a -n "$BASENAME" -o h --long pr,branch:,dep:,version:,commit:,HEAD -- "$@") - -DEPENDENCY="" -eval set -- "$PARSED_ARGS" -while :; do - case "$1" in - -h) - usage - exit 0 - ;; - --pr) - nvim -es +"lua require('scripts.bump_deps').submit_pr()" - exit 0 - ;; - --branch) - DEP=$2 - nvim -es +"lua require('scripts.bump_deps').create_branch('$DEP')" - exit 0 - ;; - --dep) - DEPENDENCY=$2 - shift 2 - ;; - --version) - VERSION=$2 - nvim -es +"lua require('scripts.bump_deps').version('$DEPENDENCY', '$VERSION')" - exit 0 - ;; - --commit) - COMMIT=$2 - nvim -es +"lua require('scripts.bump_deps').commit('$DEPENDENCY', '$COMMIT')" - exit 0 - ;; - --HEAD) - nvim -es +"lua require('scripts.bump_deps').head('$DEPENDENCY')" - exit 0 - ;; - *) - break - ;; - esac -done - -usage -exit 1 - -# vim: et sw=2 diff --git a/scripts/bump_deps.lua b/scripts/bump_deps.lua index 17e3fd35d6..1873c3cd0d 100644..100755 --- a/scripts/bump_deps.lua +++ b/scripts/bump_deps.lua @@ -1,35 +1,24 @@ +#!/usr/bin/env -S nvim -l + -- Usage: --- # bump to version --- nvim -es +"lua require('scripts.bump_deps').version(dependency, version_tag)" --- --- # bump to commit --- nvim -es +"lua require('scripts.bump_deps').commit(dependency, commit_hash)" --- --- # bump to HEAD --- nvim -es +"lua require('scripts.bump_deps').head(dependency)" --- --- # submit PR --- nvim -es +"lua require('scripts.bump_deps').submit_pr()" --- --- # create branch --- nvim -es +"lua require('scripts.bump_deps').create_branch()" +-- ./scripts/bump_deps.lua -h local M = {} local _trace = false -local required_branch_prefix = "bump-" -local commit_prefix = "build(deps): " +local required_branch_prefix = 'bump-' +local commit_prefix = 'build(deps): ' -- Print message local function p(s) - vim.cmd("set verbose=1") - vim.api.nvim_echo({ { s, "" } }, false, {}) - vim.cmd("set verbose=0") + vim.cmd('set verbose=1') + vim.api.nvim_echo({ { s, '' } }, false, {}) + vim.cmd('set verbose=0') end local function die() - p("") - vim.cmd("cquit 1") + p('') + vim.cmd('cquit 1') end -- Executes and returns the output of `cmd`, or nil on failure. @@ -37,307 +26,421 @@ end -- -- Prints `cmd` if `trace` is enabled. local function _run(cmd, die_on_fail, die_msg) - if _trace then - p("run: " .. vim.inspect(cmd)) - end - local rv = vim.trim(vim.fn.system(cmd)) or "" - if vim.v.shell_error ~= 0 then - if die_on_fail then - if _trace then - p(rv) - end - p(die_msg) - die() - end - return nil - end - return rv + if _trace then + p('run: ' .. vim.inspect(cmd)) + end + local rv = vim.trim(vim.fn.system(cmd)) or '' + if vim.v.shell_error ~= 0 then + if die_on_fail then + if _trace then + p(rv) + end + p(die_msg) + die() + end + return nil + end + return rv end -- Run a command, return nil on failure local function run(cmd) - return _run(cmd, false, "") + return _run(cmd, false, '') end -- Run a command, die on failure with err_msg local function run_die(cmd, err_msg) - return _run(cmd, true, err_msg) + return _run(cmd, true, err_msg) end local function require_executable(cmd) - local cmd_path = run_die({ "command", "-v", cmd }, cmd .. " not found!") - run_die({ "test", "-x", cmd_path }, cmd .. " is not executable") + local cmd_path = run_die({ 'command', '-v', cmd }, cmd .. ' not found!') + run_die({ 'test', '-x', cmd_path }, cmd .. ' is not executable') end local function rm_file_if_present(path_to_file) - run({ "rm", "-f", path_to_file }) + run({ 'rm', '-f', path_to_file }) end local nvim_src_dir = vim.fn.getcwd() -local temp_dir = nvim_src_dir .. "/tmp" -run({ "mkdir", "-p", temp_dir }) +local temp_dir = nvim_src_dir .. '/tmp' +run({ 'mkdir', '-p', temp_dir }) local function get_dependency(dependency_name) - local dependency_table = { - ["LuaJIT"] = { - repo = "LuaJIT/LuaJIT", - symbol = "LUAJIT", - }, - ["libuv"] = { - repo = "libuv/libuv", - symbol = "LIBUV", - }, - ["Luv"] = { - repo = "luvit/luv", - symbol = "LUV", - }, - ["tree-sitter"] = { - repo = "tree-sitter/tree-sitter", - symbol = "TREESITTER", - }, - } - local dependency = dependency_table[dependency_name] - if dependency == nil then - p("Not a dependency: " .. dependency_name) - die() - end - dependency.name = dependency_name - return dependency + local dependency_table = { + ['LuaJIT'] = { + repo = 'LuaJIT/LuaJIT', + symbol = 'LUAJIT', + }, + ['libuv'] = { + repo = 'libuv/libuv', + symbol = 'LIBUV', + }, + ['Luv'] = { + repo = 'luvit/luv', + symbol = 'LUV', + }, + ['tree-sitter'] = { + repo = 'tree-sitter/tree-sitter', + symbol = 'TREESITTER', + }, + } + local dependency = dependency_table[dependency_name] + if dependency == nil then + p('Not a dependency: ' .. dependency_name) + die() + end + dependency.name = dependency_name + return dependency end local function get_gh_commit_sha(repo, ref) - require_executable("gh") + require_executable('gh') - local sha = run_die( - { "gh", "api", "repos/" .. repo .. "/commits/" .. ref, "--jq", ".sha" }, - "Failed to get commit hash from GitHub. Not a valid ref?" - ) - return sha + local sha = run_die( + { 'gh', 'api', 'repos/' .. repo .. '/commits/' .. ref, '--jq', '.sha' }, + 'Failed to get commit hash from GitHub. Not a valid ref?' + ) + return sha end local function get_archive_info(repo, ref) - require_executable("curl") - - local archive_name = ref .. ".tar.gz" - local archive_path = temp_dir .. "/" .. archive_name - local archive_url = "https://github.com/" .. repo .. "/archive/" .. archive_name - - rm_file_if_present(archive_path) - run_die({ "curl", "-sL", archive_url, "-o", archive_path }, "Failed to download archive from GitHub") - - local archive_sha = run({ "sha256sum", archive_path }):gmatch("%w+")() - return { url = archive_url, sha = archive_sha } + require_executable('curl') + + local archive_name = ref .. '.tar.gz' + local archive_path = temp_dir .. '/' .. archive_name + local archive_url = 'https://github.com/' .. repo .. '/archive/' .. archive_name + + rm_file_if_present(archive_path) + run_die( + { 'curl', '-sL', archive_url, '-o', archive_path }, + 'Failed to download archive from GitHub' + ) + + local shacmd = (vim.fn.executable('sha256sum') == 1 + and{ 'sha256sum', archive_path } + or { 'shasum', '-a', '256', archive_path }) + local archive_sha = run(shacmd):gmatch('%w+')() + return { url = archive_url, sha = archive_sha } end local function write_cmakelists_line(symbol, kind, value) - require_executable("sed") - - local cmakelists_path = nvim_src_dir .. "/" .. "cmake.deps/CMakeLists.txt" - run_die({ - "sed", - "-i", - "-e", - "s/set(" .. symbol .. "_" .. kind .. ".*$" .. "/set(" .. symbol .. "_" .. kind .. " " .. value .. ")" .. "/", - cmakelists_path, - }, "Failed to write " .. cmakelists_path) + require_executable('sed') + + local cmakelists_path = nvim_src_dir .. '/' .. 'cmake.deps/CMakeLists.txt' + run_die({ + 'sed', + '-i', + '-e', + 's/set(' + .. symbol + .. '_' + .. kind + .. '.*$' + .. '/set(' + .. symbol + .. '_' + .. kind + .. ' ' + .. value + .. ')' + .. '/', + cmakelists_path, + }, 'Failed to write ' .. cmakelists_path) end local function explicit_create_branch(dep) - require_executable("git") - - local checked_out_branch = run({ "git", "rev-parse", "--abbrev-ref", "HEAD" }) - if checked_out_branch ~= "master" then - p("Not on master!") - die() - end - run_die({ "git", "checkout", "-b", "bump-" .. dep }, "git failed to create branch") + require_executable('git') + + local checked_out_branch = run({ 'git', 'rev-parse', '--abbrev-ref', 'HEAD' }) + if checked_out_branch ~= 'master' then + p('Not on master!') + die() + end + run_die({ 'git', 'checkout', '-b', 'bump-' .. dep }, 'git failed to create branch') end local function verify_branch(new_branch_suffix) - require_executable("git") - - local checked_out_branch = run({ "git", "rev-parse", "--abbrev-ref", "HEAD" }) - if not checked_out_branch:match("^" .. required_branch_prefix) then - p("Current branch '" .. checked_out_branch .. "' doesn't seem to start with " .. required_branch_prefix) - p("Checking out to bump-" .. new_branch_suffix) - explicit_create_branch(new_branch_suffix) - end + require_executable('git') + + local checked_out_branch = assert(run({ 'git', 'rev-parse', '--abbrev-ref', 'HEAD' })) + if not checked_out_branch:match('^' .. required_branch_prefix) then + p( + "Current branch '" + .. checked_out_branch + .. "' doesn't seem to start with " + .. required_branch_prefix + ) + p('Checking out to bump-' .. new_branch_suffix) + explicit_create_branch(new_branch_suffix) + end end local function update_cmakelists(dependency, archive, comment) - require_executable("git") - - verify_branch(dependency.name) - - local changed_file = nvim_src_dir .. "/" .. "cmake.deps/CMakeLists.txt" - - p("Updating " .. dependency.name .. " to " .. archive.url .. "\n") - write_cmakelists_line(dependency.symbol, "URL", archive.url:gsub("/", "\\/")) - write_cmakelists_line(dependency.symbol, "SHA256", archive.sha) - run_die( - { "git", "commit", changed_file, "-m", commit_prefix .. "bump " .. dependency.name .. " to " .. comment }, - "git failed to commit" - ) + require_executable('git') + + verify_branch(dependency.name) + + local changed_file = nvim_src_dir .. '/' .. 'cmake.deps/CMakeLists.txt' + + p('Updating ' .. dependency.name .. ' to ' .. archive.url .. '\n') + write_cmakelists_line(dependency.symbol, 'URL', archive.url:gsub('/', '\\/')) + write_cmakelists_line(dependency.symbol, 'SHA256', archive.sha) + run_die( + { + 'git', + 'commit', + changed_file, + '-m', + commit_prefix .. 'bump ' .. dependency.name .. ' to ' .. comment, + }, + 'git failed to commit' + ) end local function verify_cmakelists_committed() - require_executable("git") + require_executable('git') - local cmakelists_path = nvim_src_dir .. "/" .. "cmake.deps/CMakeLists.txt" - run_die({ "git", "diff", "--quiet", "HEAD", "--", cmakelists_path }, cmakelists_path .. " has uncommitted changes") + local cmakelists_path = nvim_src_dir .. '/' .. 'cmake.deps/CMakeLists.txt' + run_die( + { 'git', 'diff', '--quiet', 'HEAD', '--', cmakelists_path }, + cmakelists_path .. ' has uncommitted changes' + ) end local function warn_luv_symbol() - p("warning: " .. get_dependency("Luv").symbol .. "_VERSION will not be updated") + p('warning: ' .. get_dependency('Luv').symbol .. '_VERSION will not be updated') end -- return first 9 chars of commit local function short_commit(commit) - return string.sub(commit, 1, 9) + return string.sub(commit, 1, 9) end -- TODO: remove hardcoded fork local function gh_pr(pr_title, pr_body) - require_executable("gh") - - local pr_url = run_die({ - "gh", - "pr", - "create", - "--title", - pr_title, - "--body", - pr_body, - }, "Failed to create PR") - return pr_url + require_executable('gh') + + local pr_url = run_die({ + 'gh', + 'pr', + 'create', + '--title', + pr_title, + '--body', + pr_body, + }, 'Failed to create PR') + return pr_url end local function find_git_remote(fork) - require_executable("git") - - local remotes = run({ "git", "remote", "-v" }) - local git_remote = "" - for remote in remotes:gmatch("[^\r\n]+") do - local words = {} - for word in remote:gmatch("%w+") do - table.insert(words, word) - end - local match = words[1]:match("/github.com[:/]neovim/neovim/") - if fork == "fork" then - match = not match - end - if match and words[3] == "(fetch)" then - git_remote = words[0] - break - end - end - if git_remote == "" then - git_remote = "origin" - end - return git_remote + require_executable('git') + + local remotes = assert(run({ 'git', 'remote', '-v' })) + local git_remote = '' + for remote in remotes:gmatch('[^\r\n]+') do + local words = {} + for word in remote:gmatch('%w+') do + table.insert(words, word) + end + local match = words[1]:match('/github.com[:/]neovim/neovim/') + if fork == 'fork' then + match = not match + end + if match and words[3] == '(fetch)' then + git_remote = words[0] + break + end + end + if git_remote == '' then + git_remote = 'origin' + end + return git_remote end local function create_pr(pr_title, pr_body) - require_executable("git") - - local push_first = true - - local checked_out_branch = run({ "git", "rev-parse", "--abbrev-ref", "HEAD" }) - if push_first then - local push_remote = run({ "git", "config", "--get", "branch." .. checked_out_branch .. ".pushRemote" }) - if push_remote == nil then - push_remote = run({ "git", "config", "--get", "remote.pushDefault" }) - if push_remote == nil then - push_remote = run({ "git", "config", "--get", "branch." .. checked_out_branch .. ".remote" }) - if push_remote == nil or push_remote == find_git_remote(nil) then - push_remote = find_git_remote("fork") - end - end - end - - p("Pushing to " .. push_remote .. "/" .. checked_out_branch) - run_die({ "git", "push", push_remote, checked_out_branch }, "Git failed to push") - end - - local pr_url = gh_pr(pr_title, pr_body) - p("\nCreated PR: " .. pr_url .. "\n") + require_executable('git') + + local push_first = true + + local checked_out_branch = run({ 'git', 'rev-parse', '--abbrev-ref', 'HEAD' }) + if push_first then + local push_remote = + run({ 'git', 'config', '--get', 'branch.' .. checked_out_branch .. '.pushRemote' }) + if push_remote == nil then + push_remote = run({ 'git', 'config', '--get', 'remote.pushDefault' }) + if push_remote == nil then + push_remote = + run({ 'git', 'config', '--get', 'branch.' .. checked_out_branch .. '.remote' }) + if push_remote == nil or push_remote == find_git_remote(nil) then + push_remote = find_git_remote('fork') + end + end + end + + p('Pushing to ' .. push_remote .. '/' .. checked_out_branch) + run_die({ 'git', 'push', push_remote, checked_out_branch }, 'Git failed to push') + end + + local pr_url = gh_pr(pr_title, pr_body) + p('\nCreated PR: ' .. pr_url .. '\n') end function M.commit(dependency_name, commit) - local dependency = get_dependency(dependency_name) - verify_cmakelists_committed() - local commit_sha = get_gh_commit_sha(dependency.repo, commit) - if commit_sha ~= commit then - p("Not a commit: " .. commit .. ". Did you mean version?") - die() - end - local archive = get_archive_info(dependency.repo, commit) - if dependency_name == "Luv" then - warn_luv_symbol() - end - update_cmakelists(dependency, archive, short_commit(commit)) + local dependency = assert(get_dependency(dependency_name)) + verify_cmakelists_committed() + local commit_sha = get_gh_commit_sha(dependency.repo, commit) + if commit_sha ~= commit then + p('Not a commit: ' .. commit .. '. Did you mean version?') + die() + end + local archive = get_archive_info(dependency.repo, commit) + if dependency_name == 'Luv' then + warn_luv_symbol() + end + update_cmakelists(dependency, archive, short_commit(commit)) end function M.version(dependency_name, version) - local dependency = get_dependency(dependency_name) - verify_cmakelists_committed() - local commit_sha = get_gh_commit_sha(dependency.repo, version) - if commit_sha == version then - p("Not a version: " .. version .. ". Did you mean commit?") - die() - end - local archive = get_archive_info(dependency.repo, version) - if dependency_name == "Luv" then - write_cmakelists_line(dependency.symbol, "VERSION", version) - end - update_cmakelists(dependency, archive, version) + vim.validate{ + dependency_name={dependency_name,'s'}, + version={version,'s'}, + } + local dependency = assert(get_dependency(dependency_name)) + verify_cmakelists_committed() + local commit_sha = get_gh_commit_sha(dependency.repo, version) + if commit_sha == version then + p('Not a version: ' .. version .. '. Did you mean commit?') + die() + end + local archive = get_archive_info(dependency.repo, version) + if dependency_name == 'Luv' then + write_cmakelists_line(dependency.symbol, 'VERSION', version) + end + update_cmakelists(dependency, archive, version) end function M.head(dependency_name) - local dependency = get_dependency(dependency_name) - verify_cmakelists_committed() - local commit_sha = get_gh_commit_sha(dependency.repo, "HEAD") - local archive = get_archive_info(dependency.repo, commit_sha) - if dependency_name == "Luv" then - warn_luv_symbol() - end - update_cmakelists(dependency, archive, "HEAD - " .. short_commit(commit_sha)) + local dependency = assert(get_dependency(dependency_name)) + verify_cmakelists_committed() + local commit_sha = get_gh_commit_sha(dependency.repo, 'HEAD') + local archive = get_archive_info(dependency.repo, commit_sha) + if dependency_name == 'Luv' then + warn_luv_symbol() + end + update_cmakelists(dependency, archive, 'HEAD - ' .. short_commit(commit_sha)) end function M.create_branch(dep) - explicit_create_branch(dep) + explicit_create_branch(dep) end function M.submit_pr() - require_executable("git") - - verify_branch("deps") - - local nvim_remote = find_git_remote(nil) - local relevant_commit = run_die({ - "git", - "log", - "--grep=" .. commit_prefix, - "--reverse", - "--format='%s'", - nvim_remote .. "/master..HEAD", - "-1", - }, "Failed to fetch commits") - - local pr_title - local pr_body - - if relevant_commit == "" then - pr_title = commit_prefix .. "bump some dependencies" - pr_body = "bump some dependencies" - else - relevant_commit = relevant_commit:gsub("'", "") - pr_title = relevant_commit - pr_body = relevant_commit:gsub(commit_prefix:gsub("%(", "%%("):gsub("%)", "%%)"), "") - end - pr_body = pr_body .. "\n\n(add explanations if needed)" - p(pr_title .. "\n" .. pr_body .. "\n") - create_pr(pr_title, pr_body) + require_executable('git') + + verify_branch('deps') + + local nvim_remote = find_git_remote(nil) + local relevant_commit = assert(run_die({ + 'git', + 'log', + '--grep=' .. commit_prefix, + '--reverse', + "--format='%s'", + nvim_remote .. '/master..HEAD', + '-1', + }, 'Failed to fetch commits')) + + local pr_title + local pr_body + + if relevant_commit == '' then + pr_title = commit_prefix .. 'bump some dependencies' + pr_body = 'bump some dependencies' + else + relevant_commit = relevant_commit:gsub("'", '') + pr_title = relevant_commit + pr_body = relevant_commit:gsub(commit_prefix:gsub('%(', '%%('):gsub('%)', '%%)'), '') + end + pr_body = pr_body .. '\n\n(add explanations if needed)' + p(pr_title .. '\n' .. pr_body .. '\n') + create_pr(pr_title, pr_body) +end + +local function usage() + local this_script = _G.arg[0]:match("[^/]*.lua$") + print(([=[ + Bump Nvim dependencies + + Usage: nvim -l %s [options] + Bump to HEAD, tagged version, commit, or branch: + nvim -l %s --dep Luv --head + nvim -l %s --dep Luv --version 1.43.0-0 + nvim -l %s --dep Luv --commit abc123 + nvim -l %s --dep Luv --branch + Create a PR: + nvim -l %s --pr + + Options: + -h show this message and exit. + --pr submit pr for bumping deps. + --branch <dep> create a branch bump-<dep> from current branch. + --dep <dependency> bump to a specific release or tag. + + Dependency Options: + --version <tag> bump to a specific release or tag. + --commit <hash> bump to a specific commit. + --HEAD bump to a current head. + + <dependency> is one of: + "LuaJIT", "libuv", "Luv", "tree-sitter" + ]=]):format(this_script, this_script, this_script, this_script, this_script, this_script)) +end + +local function parseargs() + local args = {} + for i = 1, #_G.arg do + if _G.arg[i] == '-h' then + args.h = true + elseif _G.arg[i] == '--pr' then + args.pr = true + elseif _G.arg[i] == '--branch' then + args.branch = _G.arg[i+1] + elseif _G.arg[i] == '--dep' then + args.dep = _G.arg[i+1] + elseif _G.arg[i] == '--version' then + args.version = _G.arg[i+1] + elseif _G.arg[i] == '--commit' then + args.commit = _G.arg[i+1] + elseif _G.arg[i] == '--head' then + args.head = true + end + end + return args end -return M +local is_main = _G.arg[0]:match('bump_deps.lua') + +if is_main then + local args = parseargs() + if args.h then + usage() + elseif args.pr then + M.submit_pr() + elseif args.head then + M.head(args.dep) + elseif args.branch then + M.create_branch(args.dep) + elseif args.version then + M.version(args.dep, args.version) + elseif args.commit then + M.commit(args.dep, args.commit) + elseif args.pr then + M.submit_pr() + else + print('missing required arg\n') + os.exit(1) + end +else + return M +end diff --git a/scripts/check-includes.py b/scripts/check-includes.py deleted file mode 100755 index ed1fe407c5..0000000000 --- a/scripts/check-includes.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python - -import sys -import re -import os - -from subprocess import Popen, PIPE -from argparse import ArgumentParser - - -GENERATED_INCLUDE_RE = re.compile( - r'^\s*#\s*include\s*"([/a-z_0-9.]+\.generated\.h)"(\s+//.*)?$') - - -def main(argv): - argparser = ArgumentParser() - argparser.add_argument('--generated-includes-dir', action='append', - help='Directory where generated includes are located.') - argparser.add_argument('--file', type=open, help='File to check.') - argparser.add_argument('iwyu_args', nargs='*', - help='IWYU arguments, must go after --.') - args = argparser.parse_args(argv) - - with args.file: - iwyu = Popen(['include-what-you-use', '-xc'] + args.iwyu_args + ['/dev/stdin'], - stdin=PIPE, stdout=PIPE, stderr=PIPE) - - for line in args.file: - match = GENERATED_INCLUDE_RE.match(line) - if match: - for d in args.generated_includes_dir: - try: - f = open(os.path.join(d, match.group(1))) - except IOError: - continue - else: - with f: - for generated_line in f: - iwyu.stdin.write(generated_line) - break - else: - raise IOError('Failed to find {0}'.format(match.group(1))) - else: - iwyu.stdin.write(line) - - iwyu.stdin.close() - - out = iwyu.stdout.read() - err = iwyu.stderr.read() - - ret = iwyu.wait() - - if ret != 2: - print('IWYU failed with exit code {0}:'.format(ret)) - print('{0} stdout {0}'.format('=' * ((80 - len(' stdout ')) // 2))) - print(out) - print('{0} stderr {0}'.format('=' * ((80 - len(' stderr ')) // 2))) - print(err) - return 1 - return 0 - - -if __name__ == '__main__': - raise SystemExit(main(sys.argv[1:])) diff --git a/scripts/cliff.toml b/scripts/cliff.toml new file mode 100644 index 0000000000..3fc10e5d16 --- /dev/null +++ b/scripts/cliff.toml @@ -0,0 +1,73 @@ +# configuration file for git-cliff (0.1.0) + +[changelog] +# changelog header +header = """ +# Changelog\n +All notable changes to this project will be documented in this file.\n +""" +# template for the changelog body +# https://tera.netlify.app/docs/#introduction +body = """ +{% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | upper_first }} + {% for commit in commits%}\ + {% if not commit.scope %}\ + - {{ commit.message | upper_first }} + {% endif %}\ + {% endfor %}\ + {% for group, commits in commits | group_by(attribute="scope") %}\ + {% for commit in commits %}\ + - **{{commit.scope}}**: {{ commit.message | upper_first }} + {% endfor %}\ + {% endfor %} +{% endfor %}\n +""" +# remove the leading and trailing whitespace from the template +trim = true +# changelog footer +footer = """ +<!-- generated by git-cliff --> +""" + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ +# { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/neovim/neovim/issues/${2}))"}, +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "!:", group = "Breaking"}, + { message = "^feat", group = "Features"}, + { message = "^fix", group = "Bug Fixes"}, + { message = "^doc", group = "Documentation"}, + { message = "^perf", group = "Performance"}, + { message = "^refactor", group = "Refactor"}, + { message = "^test", group = "Testing"}, + { message = "^chore", group = "Miscellaneous Tasks"}, + { message = "^build", group = "Build System"}, + { message = "^Revert", group = "Reverted Changes"}, +] +# filter out the commits that are not matched by commit parsers +filter_commits = true +# glob pattern for matching git tags +tag_pattern = "v[0-9]*" +# regex for skipping tags +skip_tags = "v0.1.0-beta.1" +# regex for ignoring tags +ignore_tags = "" +# sort the tags chronologically +date_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest" diff --git a/scripts/download-unicode-files.sh b/scripts/download-unicode-files.sh index 4482cefa34..f0fd4c66ea 100755 --- a/scripts/download-unicode-files.sh +++ b/scripts/download-unicode-files.sh @@ -3,11 +3,12 @@ set -e data_files="UnicodeData.txt CaseFolding.txt EastAsianWidth.txt" emoji_files="emoji-data.txt" +files="'$data_files $emoji_files'" UNIDIR_DEFAULT=src/unicode DOWNLOAD_URL_BASE_DEFAULT='http://unicode.org/Public' -if test x$1 = 'x--help' ; then +if test "$1" = '--help' ; then echo 'Usage:' echo " $0[ TARGET_DIRECTORY[ URL_BASE]]" echo @@ -16,6 +17,7 @@ if test x$1 = 'x--help' ; then echo echo "Default target directory is $PWD/${UNIDIR_DEFAULT}." echo "Default URL base is ${DOWNLOAD_URL_BASE_DEFAULT}." + exit 0 fi UNIDIR=${1:-$UNIDIR_DEFAULT} @@ -23,21 +25,12 @@ DOWNLOAD_URL_BASE=${2:-$DOWNLOAD_URL_BASE_DEFAULT} for filename in $data_files ; do curl -L -o "$UNIDIR/$filename" "$DOWNLOAD_URL_BASE/UNIDATA/$filename" - ( - cd "$UNIDIR" - git add $filename - ) + git -C "$UNIDIR" add "$filename" done for filename in $emoji_files ; do curl -L -o "$UNIDIR/$filename" "$DOWNLOAD_URL_BASE/UNIDATA/emoji/$filename" - ( - cd "$UNIDIR" - git add $filename - ) + git -C "$UNIDIR" add "$filename" done -( - cd "$UNIDIR" - git commit -m "feat: update unicode tables" -- $files -) +git -C "$UNIDIR" commit -m "feat: update unicode tables" . diff --git a/scripts/gen_help_html.lua b/scripts/gen_help_html.lua new file mode 100644 index 0000000000..2563f2f410 --- /dev/null +++ b/scripts/gen_help_html.lua @@ -0,0 +1,1110 @@ +-- Converts Vim :help files to HTML. Validates |tag| links and document syntax (parser errors). +-- +-- NOTE: :helptags checks for duplicate tags, whereas this script checks _links_ (to tags). +-- +-- USAGE (GENERATE HTML): +-- 1. Run `make helptags` first; this script depends on vim.fn.taglist(). +-- 2. nvim -V1 -es --clean +"lua require('scripts.gen_help_html').gen('./build/runtime/doc/', 'target/dir/')" |