mirror of
https://github.com/vale981/melpazoid
synced 2025-03-04 17:01:40 -05:00
revamp and reorder melpazoid output scroll
This commit is contained in:
parent
a33c16bb82
commit
d1b40f96b1
2 changed files with 46 additions and 50 deletions
|
@ -23,8 +23,7 @@
|
||||||
|
|
||||||
(defun melpazoid-byte-compile (filename)
|
(defun melpazoid-byte-compile (filename)
|
||||||
"Wrapper for running `byte-compile-file' against FILENAME."
|
"Wrapper for running `byte-compile-file' against FILENAME."
|
||||||
;; TODO: use flycheck or its pattern for cleanroom byte-compiling
|
(melpazoid-insert "\n⸺ `%s` with byte-compile using Emacs %s:"
|
||||||
(melpazoid-insert "\n`%s` with byte-compile using Emacs %s:"
|
|
||||||
(file-name-nondirectory filename)
|
(file-name-nondirectory filename)
|
||||||
emacs-version)
|
emacs-version)
|
||||||
(melpazoid--remove-no-compile)
|
(melpazoid--remove-no-compile)
|
||||||
|
@ -77,7 +76,7 @@ affect the output of `byte-compile-file'."
|
||||||
(defun melpazoid-checkdoc (filename)
|
(defun melpazoid-checkdoc (filename)
|
||||||
"Wrapper for running `checkdoc-file' against FILENAME."
|
"Wrapper for running `checkdoc-file' against FILENAME."
|
||||||
(require 'checkdoc)
|
(require 'checkdoc)
|
||||||
(melpazoid-insert "\n`%s` with checkdoc %s (fix *within reason*):"
|
(melpazoid-insert "\n⸺ `%s` with checkdoc %s (fix *within reason*):"
|
||||||
(file-name-nondirectory filename)
|
(file-name-nondirectory filename)
|
||||||
checkdoc-version)
|
checkdoc-version)
|
||||||
(ignore-errors (kill-buffer "*Warnings*"))
|
(ignore-errors (kill-buffer "*Warnings*"))
|
||||||
|
@ -113,7 +112,7 @@ affect the output of `byte-compile-file'."
|
||||||
(ignore-errors (kill-buffer "*Package-Lint*"))
|
(ignore-errors (kill-buffer "*Package-Lint*"))
|
||||||
(let ((package-lint-main-file (melpazoid--package-lint-main-file)))
|
(let ((package-lint-main-file (melpazoid--package-lint-main-file)))
|
||||||
(melpazoid-insert
|
(melpazoid-insert
|
||||||
"\n`%s` with package-lint %s%s:"
|
"\n⸺ `%s` with package-lint %s%s:"
|
||||||
(buffer-name)
|
(buffer-name)
|
||||||
(pkg-info-format-version (pkg-info-package-version "package-lint"))
|
(pkg-info-format-version (pkg-info-package-version "package-lint"))
|
||||||
(if package-lint-main-file
|
(if package-lint-main-file
|
||||||
|
@ -181,7 +180,7 @@ a Docker container, e.g. kellyk/emacs does not include the .el files."
|
||||||
(unless (equal melpazoid--pending "")
|
(unless (equal melpazoid--pending "")
|
||||||
(setq melpazoid--pending
|
(setq melpazoid--pending
|
||||||
(format
|
(format
|
||||||
"\n`%s` with [melpazoid](https://github.com/riscy/melpazoid):\n```\n%s```\n"
|
"\n⸺ `%s` with [melpazoid](https://github.com/riscy/melpazoid):\n```\n%s```\n"
|
||||||
(buffer-name)
|
(buffer-name)
|
||||||
melpazoid--pending))
|
melpazoid--pending))
|
||||||
(melpazoid-commit-pending)))
|
(melpazoid-commit-pending)))
|
||||||
|
|
|
@ -121,7 +121,7 @@ def check_containerized_build(recipe: str, elisp_dir: Path) -> None:
|
||||||
cmd = ['make', '-C', str(_MELPAZOID_ROOT), 'image']
|
cmd = ['make', '-C', str(_MELPAZOID_ROOT), 'image']
|
||||||
subprocess.run(cmd, check=True, env=run_env)
|
subprocess.run(cmd, check=True, env=run_env)
|
||||||
|
|
||||||
_note('\n<!-- Running melpazoid tests... -->')
|
_note('\n<!-- Running tests... -->')
|
||||||
cmd = ['make', '-C', str(_MELPAZOID_ROOT), 'test']
|
cmd = ['make', '-C', str(_MELPAZOID_ROOT), 'test']
|
||||||
main_file = _main_file(files, recipe)
|
main_file = _main_file(files, recipe)
|
||||||
if main_file and sum(f.name.endswith('.el') for f in pkg_dir.iterdir()) > 1:
|
if main_file and sum(f.name.endswith('.el') for f in pkg_dir.iterdir()) > 1:
|
||||||
|
@ -141,7 +141,6 @@ def check_containerized_build(recipe: str, elisp_dir: Path) -> None:
|
||||||
_note(line, CLR_INFO)
|
_note(line, CLR_INFO)
|
||||||
elif not line.startswith('make[1]: Leaving directory'):
|
elif not line.startswith('make[1]: Leaving directory'):
|
||||||
print(line)
|
print(line)
|
||||||
print()
|
|
||||||
print_packaging(recipe, elisp_dir)
|
print_packaging(recipe, elisp_dir)
|
||||||
|
|
||||||
|
|
||||||
|
@ -332,10 +331,8 @@ def _reqs_from_el_file(el_file: TextIO) -> set[str]:
|
||||||
|
|
||||||
def _check_license_api(clone_address: str) -> bool:
|
def _check_license_api(clone_address: str) -> bool:
|
||||||
"""Use the GitHub or GitLab API to check for a license.
|
"""Use the GitHub or GitLab API to check for a license.
|
||||||
Prints out the particular license as a side effect.
|
|
||||||
Return False if unable to check (e.g. it's not on GitHub).
|
Return False if unable to check (e.g. it's not on GitHub).
|
||||||
>>> _check_license_api('https://github.com/riscy/elfmt')
|
>>> _check_license_api('https://github.com/riscy/elfmt')
|
||||||
- GNU General Public License v3.0 (via repo API)
|
|
||||||
True
|
True
|
||||||
"""
|
"""
|
||||||
repo_info = _repo_info_api(clone_address)
|
repo_info = _repo_info_api(clone_address)
|
||||||
|
@ -367,7 +364,7 @@ def _check_license_api(clone_address: str) -> bool:
|
||||||
'Mozilla Public License 2.0',
|
'Mozilla Public License 2.0',
|
||||||
'The Unlicense',
|
'The Unlicense',
|
||||||
}
|
}
|
||||||
print(f"- {license_.get('name')} (via repo API)")
|
|
||||||
if license_.get('name') in gpl_compatible_licensee_licenses:
|
if license_.get('name') in gpl_compatible_licensee_licenses:
|
||||||
pass
|
pass
|
||||||
elif license_.get('name') == 'Other':
|
elif license_.get('name') == 'Other':
|
||||||
|
@ -492,14 +489,25 @@ def _spdx_license(license_id: str) -> dict[str, Any] | None:
|
||||||
|
|
||||||
def print_packaging(recipe: str, elisp_dir: Path) -> None:
|
def print_packaging(recipe: str, elisp_dir: Path) -> None:
|
||||||
"""Print additional details (how it's licensed, what files, etc.)"""
|
"""Print additional details (how it's licensed, what files, etc.)"""
|
||||||
_note('Package and license:', CLR_INFO)
|
print('\n⸺ Package and license:')
|
||||||
_check_recipe(recipe, elisp_dir)
|
_check_recipe(recipe, elisp_dir)
|
||||||
_check_package_requires(recipe, elisp_dir)
|
_check_package_requires(recipe, elisp_dir)
|
||||||
_check_url(recipe, elisp_dir)
|
_check_url(recipe, elisp_dir)
|
||||||
_check_package_tags(recipe)
|
|
||||||
_check_license(recipe, elisp_dir)
|
_check_license(recipe, elisp_dir)
|
||||||
_check_filenames(recipe, elisp_dir)
|
_check_other(recipe, elisp_dir)
|
||||||
print()
|
_check_package_tags(recipe)
|
||||||
|
for file in _files_in_recipe(recipe, elisp_dir):
|
||||||
|
relpath = file.relative_to(elisp_dir)
|
||||||
|
if file.is_dir():
|
||||||
|
print(f"- pkg/{relpath} -- directory")
|
||||||
|
continue
|
||||||
|
with file.open(encoding='utf-8', errors='replace') as stream:
|
||||||
|
boilerplate = _check_file_for_license_boilerplate(stream)
|
||||||
|
print(f"- pkg/{relpath}: {boilerplate or 'license unknown'}")
|
||||||
|
if repo_info := _repo_info_api(_clone_address(recipe)):
|
||||||
|
print('- Repository:', (repo_info['license'] or {}).get('name'))
|
||||||
|
if repo_info.get('archived'):
|
||||||
|
_fail('- GitHub repository is archived')
|
||||||
|
|
||||||
|
|
||||||
def _check_url(recipe: str, elisp_dir: Path) -> None:
|
def _check_url(recipe: str, elisp_dir: Path) -> None:
|
||||||
|
@ -527,7 +535,7 @@ def _check_package_tags(recipe: str) -> None:
|
||||||
_note(reminder, CLR_WARN)
|
_note(reminder, CLR_WARN)
|
||||||
|
|
||||||
|
|
||||||
def _check_filenames(recipe: str, elisp_dir: Path) -> None:
|
def _check_other(recipe: str, elisp_dir: Path) -> None:
|
||||||
for file in _files_in_recipe(recipe, elisp_dir):
|
for file in _files_in_recipe(recipe, elisp_dir):
|
||||||
if not file.name.endswith('.el'):
|
if not file.name.endswith('.el'):
|
||||||
continue
|
continue
|
||||||
|
@ -538,25 +546,14 @@ def _check_filenames(recipe: str, elisp_dir: Path) -> None:
|
||||||
+ f"MELPA can create one from {package_name(recipe)}.el",
|
+ f"MELPA can create one from {package_name(recipe)}.el",
|
||||||
CLR_WARN,
|
CLR_WARN,
|
||||||
)
|
)
|
||||||
elif file.name.endswith('-pkg.el'):
|
continue
|
||||||
|
if file.name.endswith('-pkg.el'):
|
||||||
_fail(f"- {relpath} -- files ending in `-pkg.el` are only for packaging")
|
_fail(f"- {relpath} -- files ending in `-pkg.el` are only for packaging")
|
||||||
|
continue
|
||||||
prefix = package_name(recipe)
|
prefix = package_name(recipe)
|
||||||
prefix = prefix[:-5] if prefix.endswith('-mode') else prefix
|
prefix = prefix[:-5] if prefix.endswith('-mode') else prefix
|
||||||
if not re.match(f"^{prefix}[-.]", file.name):
|
if not re.match(f"^{prefix}[-.]", file.name):
|
||||||
_fail(f"- {relpath} -- not in package namespace `{prefix}-`")
|
_fail(f"- {relpath} -- not in package namespace `{prefix}-`")
|
||||||
|
|
||||||
|
|
||||||
def _check_license(recipe: str, elisp_dir: Path) -> None:
|
|
||||||
if not _check_license_api(_clone_address(recipe)):
|
|
||||||
_check_license_file(elisp_dir)
|
|
||||||
for file in _files_in_recipe(recipe, elisp_dir):
|
|
||||||
relpath = file.relative_to(elisp_dir)
|
|
||||||
if file.is_dir():
|
|
||||||
print(f"- {relpath} -- directory")
|
|
||||||
continue
|
|
||||||
if not file.name.endswith('.el') or file.name.endswith('-pkg.el'):
|
|
||||||
print(f"- {relpath} -- not elisp code")
|
|
||||||
continue
|
|
||||||
with file.open(encoding='utf-8', errors='replace') as stream:
|
with file.open(encoding='utf-8', errors='replace') as stream:
|
||||||
try:
|
try:
|
||||||
header = stream.readline()
|
header = stream.readline()
|
||||||
|
@ -564,17 +561,21 @@ def _check_license(recipe: str, elisp_dir: Path) -> None:
|
||||||
header = header.split(' --- ')[1]
|
header = header.split(' --- ')[1]
|
||||||
header = header.strip()
|
header = header.strip()
|
||||||
except IndexError:
|
except IndexError:
|
||||||
header = f"{CLR_ERROR}(no header){CLR_OFF}"
|
_fail(f"- {relpath} -- no packaging header")
|
||||||
_return_code(2)
|
|
||||||
boilerplate = _check_file_for_license_boilerplate(stream)
|
|
||||||
print(
|
def _check_license(recipe: str, elisp_dir: Path) -> None:
|
||||||
f"- {relpath} -- {boilerplate or 'unknown license'}"
|
if not _check_license_api(_clone_address(recipe)):
|
||||||
+ (f" -- {header}" if header else "")
|
_check_license_file(elisp_dir)
|
||||||
)
|
for file in _files_in_recipe(recipe, elisp_dir):
|
||||||
if boilerplate is None:
|
if not file.name.endswith('.el'):
|
||||||
|
continue
|
||||||
|
relpath = file.relative_to(elisp_dir)
|
||||||
|
with file.open(encoding='utf-8', errors='replace') as stream:
|
||||||
|
if not _check_file_for_license_boilerplate(stream):
|
||||||
_fail(
|
_fail(
|
||||||
f" - {relpath} needs *formal* license boilerplate and/or an"
|
f"- {relpath} needs *formal* license boilerplate and/or an"
|
||||||
" [SPDX-License-Identifier](https://spdx.dev/ids/)"
|
+ " [SPDX-License-Identifier](https://spdx.dev/ids/)"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -595,7 +596,7 @@ def _check_recipe(recipe: str, elisp_dir: Path) -> None:
|
||||||
try:
|
try:
|
||||||
files_default_recipe = _files_in_recipe(_default_recipe(recipe), elisp_dir)
|
files_default_recipe = _files_in_recipe(_default_recipe(recipe), elisp_dir)
|
||||||
except ChildProcessError:
|
except ChildProcessError:
|
||||||
_note(f"Default recipe is unusable: {_default_recipe(recipe)}")
|
_note(f"<!-- Default recipe is unusable: {_default_recipe(recipe)} -->")
|
||||||
files_default_recipe = []
|
files_default_recipe = []
|
||||||
if files == files_default_recipe:
|
if files == files_default_recipe:
|
||||||
_note(f"- Prefer equivalent recipe: `{_default_recipe(recipe)}`", CLR_WARN)
|
_note(f"- Prefer equivalent recipe: `{_default_recipe(recipe)}`", CLR_WARN)
|
||||||
|
@ -654,7 +655,7 @@ def check_package_name(name: str) -> None:
|
||||||
)
|
)
|
||||||
name_reserved = any(re.match(reserved, name) for reserved in reserved_names)
|
name_reserved = any(re.match(reserved, name) for reserved in reserved_names)
|
||||||
if name_reserved:
|
if name_reserved:
|
||||||
_note('Package name:', CLR_INFO)
|
print('\n⸺ Package name:')
|
||||||
_fail(f"- Error: `{name}` is reserved\n", highlight='Error')
|
_fail(f"- Error: `{name}` is reserved\n", highlight='Error')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -664,7 +665,7 @@ def check_package_name(name: str) -> None:
|
||||||
except ChildProcessError:
|
except ChildProcessError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
_note('Package name:', CLR_INFO)
|
print('\n⸺ Package name:')
|
||||||
_fail(f"- Error: `{name}` is an Emacs builtin\n", highlight='Error')
|
_fail(f"- Error: `{name}` is an Emacs builtin\n", highlight='Error')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -681,7 +682,7 @@ def check_package_name(name: str) -> None:
|
||||||
resolved_same.update(elpa_packages(*same_names))
|
resolved_same.update(elpa_packages(*same_names))
|
||||||
resolved_same.update(melpa_packages(*same_names))
|
resolved_same.update(melpa_packages(*same_names))
|
||||||
for name_, url in resolved_same.items():
|
for name_, url in resolved_same.items():
|
||||||
_note('Package name:', CLR_INFO)
|
print('\n⸺ Package name:')
|
||||||
_fail(f"- `{name_}` already exists: {url}\n")
|
_fail(f"- `{name_}` already exists: {url}\n")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -703,10 +704,9 @@ def check_package_name(name: str) -> None:
|
||||||
)
|
)
|
||||||
if similar_names:
|
if similar_names:
|
||||||
similar_names.update(melpa_packages(*similar_names.keys()))
|
similar_names.update(melpa_packages(*similar_names.keys()))
|
||||||
_note('Package name:', CLR_INFO)
|
print('\n⸺ Package name:')
|
||||||
for name_, url in similar_names.items():
|
for name_, url in similar_names.items():
|
||||||
print(f"- `{name_}` is similar: {url}")
|
print(f"- `{name_}` is similar: {url}")
|
||||||
print()
|
|
||||||
|
|
||||||
|
|
||||||
@functools.lru_cache
|
@functools.lru_cache
|
||||||
|
@ -913,12 +913,9 @@ def check_melpa_pr(pr_url: str) -> None:
|
||||||
check_containerized_build(recipe, elisp_dir)
|
check_containerized_build(recipe, elisp_dir)
|
||||||
if os.environ.get('EXIST_OK', '').lower() != 'true':
|
if os.environ.get('EXIST_OK', '').lower() != 'true':
|
||||||
check_package_name(package_name(recipe))
|
check_package_name(package_name(recipe))
|
||||||
print('<!-- Footnotes:')
|
print('\n<!-- PR reviewer footnotes:')
|
||||||
_note(f"- {_prettify_recipe(recipe)}", CLR_INFO, ':[^ ]+')
|
_note(f"- {_prettify_recipe(recipe)}", CLR_INFO, ':[^ ]+')
|
||||||
repo_info = _repo_info_api(_clone_address(recipe))
|
if repo_info := _repo_info_api(_clone_address(recipe)):
|
||||||
if repo_info:
|
|
||||||
if repo_info.get('archived'):
|
|
||||||
_fail('- GitHub repository is archived')
|
|
||||||
print(f"- Created: {repo_info.get('created_at', 'N/A')}")
|
print(f"- Created: {repo_info.get('created_at', 'N/A')}")
|
||||||
print(f"- Updated: {repo_info.get('updated_at', 'N/A')}")
|
print(f"- Updated: {repo_info.get('updated_at', 'N/A')}")
|
||||||
print(f"- Watched: {repo_info.get('watchers_count', 'N/A')}")
|
print(f"- Watched: {repo_info.get('watchers_count', 'N/A')}")
|
||||||
|
|
Loading…
Add table
Reference in a new issue