diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/finddeclarations.pl | 50 | ||||
-rwxr-xr-x | scripts/gen_vimdoc.py | 9 | ||||
-rw-r--r-- | scripts/lintcommit.lua | 4 | ||||
-rwxr-xr-x | scripts/pvscheck.sh | 5 | ||||
-rwxr-xr-x | scripts/release.sh | 4 | ||||
-rw-r--r-- | scripts/squash_typos.py | 94 | ||||
-rwxr-xr-x | scripts/vim-patch.sh | 43 |
7 files changed, 112 insertions, 97 deletions
diff --git a/scripts/finddeclarations.pl b/scripts/finddeclarations.pl deleted file mode 100755 index 1b1a57b9b7..0000000000 --- a/scripts/finddeclarations.pl +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -if ($ARGV[0] eq '--help') { - print << "EOF"; -Usage: - - $0 definitions.c -EOF - exit; -} - -my ($cfname, $sfname, $gfname, $cpp) = @ARGV; - -my $F; - -open $F, "<", $cfname; - -my $text = join "", <$F>; - -close $F; - -my $s = qr/(?>\s*)/aso; -my $w = qr/(?>\w+)/aso; -my $argname = qr/$w(?:\[(?>\w+)\])?/aso; -my $type_regex = qr/(?:$w$s\**$s)+/aso; -my $arg_regex = qr/(?:$type_regex$s$argname)/aso; - -while ($text =~ / - (?<=\n) # Definition starts at the start of line - $type_regex # Return type - $s$w # Function name - $s\($s - (?: - $arg_regex(?:$s,$s$arg_regex)*+ - ($s,$s\.\.\.)? # varargs function - |void - )? - $s\) - (?:$s FUNC_ATTR_$w(?:\((?>[^)]*)\))?)*+ # Optional attributes - (?=$s;) # Ending semicolon - /axsogp) { - my $match = "${^MATCH}"; - my $s = "${^PREMATCH}"; - $s =~ s/[^\n]++//g; - my $line = 1 + length $s; - print "${cfname}:${line}: $match\n"; -} diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 64ed8d61f6..7f4dccfd3c 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -91,6 +91,7 @@ CONFIG = { 'vim.c', 'buffer.c', 'window.c', + 'win_config.c', 'tabpage.c', 'ui.c', ], @@ -123,11 +124,13 @@ CONFIG = { 'vim.lua', 'shared.lua', 'uri.lua', + 'ui.lua', ], 'files': ' '.join([ os.path.join(base_dir, 'src/nvim/lua/vim.lua'), os.path.join(base_dir, 'runtime/lua/vim/shared.lua'), os.path.join(base_dir, 'runtime/lua/vim/uri.lua'), + os.path.join(base_dir, 'runtime/lua/vim/ui.lua'), ]), 'file_patterns': '*.lua', 'fn_name_prefix': '', @@ -141,6 +144,7 @@ CONFIG = { # `shared` functions are exposed on the `vim` module. 'shared': 'vim', 'uri': 'vim', + 'ui': 'vim.ui', }, 'append_only': [ 'shared.lua', @@ -502,6 +506,11 @@ def render_node(n, text, prefix='', indent='', width=62): text += indent + prefix + result elif n.nodeName in ('para', 'heading'): for c in n.childNodes: + if (is_inline(c) + and '' != get_text(c).strip() + and text + and ' ' != text[-1]): + text += ' ' text += render_node(c, text, indent=indent, width=width) elif n.nodeName == 'itemizedlist': for c in n.childNodes: diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index 11ad8eb9ef..c30a1b10da 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -91,7 +91,7 @@ local function validate_commit(commit_message) -- Check that description doesn't end with a period if vim.endswith(after_colon, ".") then - return [[Description ends with a period (\".\").]] + return [[Description ends with a period (".").]] end -- Check that description has exactly one whitespace after colon, followed by @@ -106,7 +106,7 @@ end function M.main(opt) _trace = not opt or not not opt.trace - local branch = run({'git', 'branch', '--show-current'}, true) + local branch = run({'git', 'rev-parse', '--abbrev-ref', 'HEAD'}, true) -- TODO(justinmk): check $GITHUB_REF local ancestor = run({'git', 'merge-base', 'origin/master', branch}) if not ancestor then diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh index aa27c94f29..195a76763f 100755 --- a/scripts/pvscheck.sh +++ b/scripts/pvscheck.sh @@ -373,13 +373,14 @@ run_analysis() {( analyze \ --lic-file PVS-Studio.lic \ --threads "$(get_jobs_num)" \ - --exclude-path src/nvim/xdiff \ + --exclude-path src/cjson \ + --exclude-path src/xdiff \ --output-file PVS-studio.log \ --file build/compile_commands.json \ --sourcetree-root . || true rm -rf PVS-studio.{xml,err,tsk,html.d} - local plog_args="PVS-studio.log --srcRoot . --excludedCodes V011,V1042" + local plog_args="PVS-studio.log --srcRoot . --excludedCodes V011,V1042,V1051,V1074" plog-converter $plog_args --renderTypes xml --output PVS-studio.xml plog-converter $plog_args --renderTypes errorfile --output PVS-studio.err plog-converter $plog_args --renderTypes tasklist --output PVS-studio.tsk diff --git a/scripts/release.sh b/scripts/release.sh index 4ec959d697..380503662d 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -80,8 +80,8 @@ _do_release_commit() { _do_bump_commit() { $__sed -i.bk 's/(NVIM_VERSION_PRERELEASE) ""/\1 "-dev"/' CMakeLists.txt $__sed -i.bk 's/set\((NVIM_VERSION_PATCH) [[:digit:]]/set(\1 ?/' CMakeLists.txt - rm CMakeLists.txt.bk - rm runtime/nvim.appdata.xml.bk + rm -f CMakeLists.txt.bk + rm -f runtime/nvim.appdata.xml.bk nvim +'/NVIM_VERSION' +1new +'exe "norm! iUpdate version numbers!!!"' \ -O CMakeLists.txt diff --git a/scripts/squash_typos.py b/scripts/squash_typos.py index 26be6010a2..b403a9b7c8 100644 --- a/scripts/squash_typos.py +++ b/scripts/squash_typos.py @@ -22,24 +22,40 @@ def get_authors_and_emails_from_pr(): # Get a list of all authors involved in the pull request (including co-authors). authors = subprocess.check_output( - ["gh", "pr", "view", "--json", "commits", "--jq", ".[][].authors.[].name"], + [ + "gh", + "pr", + "view", + os.environ["PR_NUMBER"], + "--json", + "commits", + "--jq", + ".[][].authors.[].name", + ], text=True, ).splitlines() # Get a list of emails of the aforementioned authors. emails = subprocess.check_output( - ["gh", "pr", "view", "--json", "commits", "--jq", ".[][].authors.[].email"], + [ + "gh", + "pr", + "view", + os.environ["PR_NUMBER"], + "--json", + "commits", + "--jq", + ".[][].authors.[].email", + ], text=True, ).splitlines() - authors_and_emails_unique = { - (author, mail) for author, mail in zip(authors, emails) - } + authors_and_emails = [(author, mail) for author, mail in zip(authors, emails)] - return sorted(authors_and_emails_unique) + return authors_and_emails -def rebase_squash_branch_onto_pr(): +def rebase_onto_pr(): """ Rebase current branch onto the PR. @@ -49,9 +65,7 @@ def rebase_squash_branch_onto_pr(): # Check out the pull request. subprocess.call(["gh", "pr", "checkout", os.environ["PR_NUMBER"]]) - # Rebase onto master - default_branch = f"{os.environ['GITHUB_BASE_REF']}" - subprocess.check_call(["git", "rebase", default_branch]) + rebase_onto_master() # Change back to the original branch. subprocess.call(["git", "switch", "-"]) @@ -87,7 +101,7 @@ def rebase_squash_branch_onto_pr(): ) -def rebase_squash_branch_onto_master(): +def rebase_onto_master(): """ Rebase current branch onto the master i.e. make sure current branch is up @@ -99,7 +113,7 @@ def rebase_squash_branch_onto_master(): subprocess.check_call(["git", "rebase", default_branch]) -def squash_all_commits(): +def squash_all_commits(message_body_before): """ Squash all commits on the PR into a single commit. Credit all authors by @@ -111,8 +125,11 @@ def squash_all_commits(): subprocess.call(["git", "reset", "--soft", default_branch]) authors_and_emails = get_authors_and_emails_from_pr() - commit_message_coauthors = "\n" + "\n".join( - [f"Co-authored-by: {i[0]} <{i[1]}>" for i in authors_and_emails] + commit_message_coauthors = ( + "\n" + + "\n".join([f"Co-authored-by: {i[0]} <{i[1]}>" for i in authors_and_emails]) + + "\n" + + message_body_before ) subprocess.call( ["git", "commit", "-m", "chore: typo fixes", "-m", commit_message_coauthors] @@ -164,7 +181,7 @@ def checkout_branch(branch): return False -def get_all_pr_urls(squash_branch_exists): +def get_all_pr_urls(pr_branch_exists): """ Return a list of URLs for the pull requests with the typo fixes. If a @@ -173,7 +190,7 @@ def get_all_pr_urls(squash_branch_exists): """ all_pr_urls = "" - if squash_branch_exists: + if pr_branch_exists: all_pr_urls += subprocess.check_output( ["gh", "pr", "view", "--json", "body", "--jq", ".body"], text=True ) @@ -187,15 +204,21 @@ def get_all_pr_urls(squash_branch_exists): def main(): - squash_branch = "marvim/squash-typos" + pr_branch = "marvim/squash-typos" - squash_branch_exists = checkout_branch(squash_branch) + pr_branch_exists = checkout_branch(pr_branch) - rebase_squash_branch_onto_master() - force_push(squash_branch) + rebase_onto_master() + force_push(pr_branch) + + message_body_before = "\n".join( + subprocess.check_output( + ["git", "log", "--format=%B", "-n1", pr_branch], text=True + ).splitlines()[2:] + ) - rebase_squash_branch_onto_pr() - force_push(squash_branch) + rebase_onto_pr() + force_push(pr_branch) subprocess.call( [ @@ -204,20 +227,37 @@ def main(): "create", "--fill", "--head", - squash_branch, + pr_branch, "--title", "chore: typo fixes (automated)", - ] + ], + text=True, ) - squash_all_commits() - force_push(squash_branch) + squash_all_commits(message_body_before) + force_push(pr_branch) - all_pr_urls = get_all_pr_urls(squash_branch_exists) + all_pr_urls = get_all_pr_urls(pr_branch_exists) subprocess.call(["gh", "pr", "edit", "--add-label", "typo", "--body", all_pr_urls]) subprocess.call(["gh", "pr", "close", os.environ["PR_NUMBER"]]) + squash_url = subprocess.check_output( + ["gh", "pr", "view", "--json", "url", "--jq", ".url"], text=True + ).strip() + subprocess.call( + [ + "gh", + "pr", + "comment", + os.environ["PR_NUMBER"], + "--body", + f"Thank you for your contribution! We collect all typo fixes \ + into a single pull request and merge it once it gets big enough: \ + {squash_url}", + ] + ) + if __name__ == "__main__": main() diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index f4b817dfff..d92480abb9 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -125,8 +125,12 @@ commit_message() { } find_git_remote() { - git_remote=$(git remote -v \ - | awk '$2 ~ /github.com[:\/]neovim\/neovim/ && $3 == "(fetch)" {print $1; exit}') + local git_remote + if [[ "${1-}" == fork ]]; then + git_remote=$(git remote -v | awk '$2 !~ /github.com[:\/]neovim\/neovim/ && $3 == "(fetch)" {print $1; exit}') + else + git_remote=$(git remote -v | awk '$2 ~ /github.com[:\/]neovim\/neovim/ && $3 == "(fetch)" {print $1; exit}') + fi if [[ -z "$git_remote" ]]; then git_remote="origin" fi @@ -268,8 +272,8 @@ stage_patch() { get_vimpatch "$1" local try_apply="${2:-}" - local git_remote - git_remote="$(find_git_remote)" + local nvim_remote + nvim_remote="$(find_git_remote)" local checked_out_branch checked_out_branch="$(git rev-parse --abbrev-ref HEAD)" @@ -277,16 +281,16 @@ stage_patch() { msg_ok "Current branch '${checked_out_branch}' seems to be a vim-patch" echo " branch; not creating a new branch." else - printf '\nFetching "%s/master".\n' "${git_remote}" - output="$(git fetch "${git_remote}" master 2>&1)" && + printf '\nFetching "%s/master".\n' "${nvim_remote}" + output="$(git fetch "${nvim_remote}" master 2>&1)" && msg_ok "${output}" || (msg_err "${output}"; false) local nvim_branch="${BRANCH_PREFIX}${vim_version}" echo - echo "Creating new branch '${nvim_branch}' based on '${git_remote}/master'." + echo "Creating new branch '${nvim_branch}' based on '${nvim_remote}/master'." cd "${NVIM_SOURCE_DIR}" - output="$(git checkout -b "${nvim_branch}" "${git_remote}/master" 2>&1)" && + output="$(git checkout -b "${nvim_branch}" "${nvim_remote}/master" 2>&1)" && msg_ok "${output}" || (msg_err "${output}"; false) fi @@ -362,13 +366,13 @@ submit_pr() { exit 1 fi - local git_remote - git_remote="$(find_git_remote)" + local nvim_remote + nvim_remote="$(find_git_remote)" local pr_body - pr_body="$(git log --grep=vim-patch --reverse --format='#### %s%n%n%b%n' "${git_remote}"/master..HEAD)" + pr_body="$(git log --grep=vim-patch --reverse --format='#### %s%n%n%b%n' "${nvim_remote}"/master..HEAD)" local patches # Extract just the "vim-patch:X.Y.ZZZZ" or "vim-patch:sha" portion of each log - patches=("$(git log --grep=vim-patch --reverse --format='%s' "${git_remote}"/master..HEAD | sed 's/: .*//')") + patches=("$(git log --grep=vim-patch --reverse --format='%s' "${nvim_remote}"/master..HEAD | sed 's/: .*//')") # shellcheck disable=SC2206 patches=(${patches[@]//vim-patch:}) # Remove 'vim-patch:' prefix for each item in array. local pr_title="${patches[*]}" # Create space-separated string from array. @@ -376,8 +380,19 @@ submit_pr() { pr_title="$(printf 'vim-patch:%s' "${pr_title#,}")" if [[ $push_first -ne 0 ]]; then - echo "Pushing to 'origin/${checked_out_branch}'." - output="$(git push origin "${checked_out_branch}" 2>&1)" && + local push_remote + push_remote="$(git config --get branch."${checked_out_branch}".pushRemote || true)" + if [[ -z "$push_remote" ]]; then + push_remote="$(git config --get remote.pushDefault || true)" + if [[ -z "$push_remote" ]]; then + push_remote="$(git config --get branch."${checked_out_branch}".remote || true)" + if [[ -z "$push_remote" ]] || [[ "$push_remote" == "$nvim_remote" ]]; then + push_remote="$(find_git_remote fork)" + fi + fi + fi + echo "Pushing to '${push_remote}/${checked_out_branch}'." + output="$(git push "${push_remote}" "${checked_out_branch}" 2>&1)" && msg_ok "${output}" || (msg_err "${output}"; false) |