mirror of
https://github.com/vale981/melpazoid
synced 2025-03-06 01:41:38 -05:00
simplify some of the containerized output
This commit is contained in:
parent
ecda3c85cd
commit
16232df715
2 changed files with 25 additions and 27 deletions
26
melpazoid.el
26
melpazoid.el
|
@ -39,7 +39,8 @@
|
||||||
(melpazoid-insert "- No issues!")
|
(melpazoid-insert "- No issues!")
|
||||||
(goto-char (point-min)) (forward-line 2)
|
(goto-char (point-min)) (forward-line 2)
|
||||||
(melpazoid-insert "```")
|
(melpazoid-insert "```")
|
||||||
(melpazoid-insert (buffer-substring (point) (point-max)))
|
(melpazoid-insert
|
||||||
|
(melpazoid--newline-trim (buffer-substring (point) (point-max))))
|
||||||
(melpazoid-insert "```")
|
(melpazoid-insert "```")
|
||||||
(setq melpazoid-error-p t)))
|
(setq melpazoid-error-p t)))
|
||||||
(melpazoid-insert ""))
|
(melpazoid-insert ""))
|
||||||
|
@ -49,11 +50,8 @@
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(unless (re-search-forward "lexical-binding:[[:blank:]]*t" nil t)
|
(unless (re-search-forward "lexical-binding:[[:blank:]]*t" nil t)
|
||||||
(melpazoid-insert
|
(melpazoid-insert "- Per CONTRIBUTING.org, consider using lexical binding.")
|
||||||
(concat
|
(melpazoid-insert " See: https://github.com/melpa/melpa/blob/master/CONTRIBUTING.org#fixing-typical-problems")
|
||||||
"- Per CONTRIBUTING.org, consider"
|
|
||||||
" [using lexical binding](https://github.com/melpa/melpa/blob/master/CONTRIBUTING.org#fixing-typical-problems)"
|
|
||||||
" (you will need at least emacs 24)"))
|
|
||||||
(melpazoid-insert "- Lexical binding will be used in what follows"))))
|
(melpazoid-insert "- Lexical binding will be used in what follows"))))
|
||||||
|
|
||||||
(defun melpazoid--remove-no-compile ()
|
(defun melpazoid--remove-no-compile ()
|
||||||
|
@ -87,7 +85,8 @@
|
||||||
(melpazoid-insert "- No issues!")
|
(melpazoid-insert "- No issues!")
|
||||||
(with-current-buffer "*Warnings*"
|
(with-current-buffer "*Warnings*"
|
||||||
(melpazoid-insert "```")
|
(melpazoid-insert "```")
|
||||||
(melpazoid-insert (buffer-substring (point-min) (point-max)))
|
(melpazoid-insert
|
||||||
|
(melpazoid--newline-trim (buffer-substring (point-min) (point-max))))
|
||||||
(melpazoid-insert "```")
|
(melpazoid-insert "```")
|
||||||
(setq melpazoid-error-p t)))
|
(setq melpazoid-error-p t)))
|
||||||
(melpazoid-insert ""))
|
(melpazoid-insert ""))
|
||||||
|
@ -104,7 +103,7 @@
|
||||||
(ignore-errors (kill-buffer "*Package-Lint*"))
|
(ignore-errors (kill-buffer "*Package-Lint*"))
|
||||||
(ignore-errors (package-lint-current-buffer))
|
(ignore-errors (package-lint-current-buffer))
|
||||||
(with-current-buffer (get-buffer-create "*Package-Lint*")
|
(with-current-buffer (get-buffer-create "*Package-Lint*")
|
||||||
(let ((output (melpazoid--string-trim (buffer-substring (point-min) (point-max)))))
|
(let ((output (melpazoid--newline-trim (buffer-substring (point-min) (point-max)))))
|
||||||
(if (string= "No issues found." output)
|
(if (string= "No issues found." output)
|
||||||
(melpazoid-insert "- No issues!")
|
(melpazoid-insert "- No issues!")
|
||||||
(melpazoid-insert "```")
|
(melpazoid-insert "```")
|
||||||
|
@ -225,18 +224,17 @@ then also scan comments for REGEXP."
|
||||||
(defun melpazoid-insert (f-str &rest objects)
|
(defun melpazoid-insert (f-str &rest objects)
|
||||||
"Insert F-STR in a way determined by whether we're in script mode.
|
"Insert F-STR in a way determined by whether we're in script mode.
|
||||||
OBJECTS are objects to interpolate into the string using `format'."
|
OBJECTS are objects to interpolate into the string using `format'."
|
||||||
(let* ((str (concat (melpazoid--string-trim f-str) "\n"))
|
(let* ((str (concat f-str "\n"))
|
||||||
(str (apply #'format str objects)))
|
(str (apply #'format str objects)))
|
||||||
(if noninteractive
|
(if noninteractive
|
||||||
(send-string-to-terminal str)
|
(send-string-to-terminal str)
|
||||||
(with-current-buffer (get-buffer-create melpazoid-buffer)
|
(with-current-buffer (get-buffer-create melpazoid-buffer)
|
||||||
(insert str)))))
|
(insert str)))))
|
||||||
|
|
||||||
(defun melpazoid--string-trim (str)
|
(defun melpazoid--newline-trim (str)
|
||||||
"Sanitize STR. This is like `string-trim' without the 'require'.
|
"Sanitize STR by removing newlines."
|
||||||
\(The 'require' can affect melpazoid's byte-compilation output.)"
|
(let* ((str (replace-regexp-in-string "[\n]+$" "" str))
|
||||||
(let* ((str (replace-regexp-in-string "[[:space:]]+$" "" str))
|
(str (replace-regexp-in-string "^[\n]+" "" str)))
|
||||||
(str (replace-regexp-in-string "^[[:space:]]+" "" str)))
|
|
||||||
str))
|
str))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
26
melpazoid.py
26
melpazoid.py
|
@ -95,8 +95,8 @@ def _note(message: str, color: str = None, highlight: str = None):
|
||||||
print(f"{color}{message}{CLR_OFF}")
|
print(f"{color}{message}{CLR_OFF}")
|
||||||
|
|
||||||
|
|
||||||
def _fail(message: str, highlight: str = None):
|
def _fail(message: str, color: str = CLR_ERR, highlight: str = None):
|
||||||
_note(message, CLR_ERR, highlight)
|
_note(message, color, highlight)
|
||||||
return_code(1)
|
return_code(1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ def _requirements(
|
||||||
|
|
||||||
|
|
||||||
def check_license(recipe_files: list, elisp_dir: str, clone_address: str = None):
|
def check_license(recipe_files: list, elisp_dir: str, clone_address: str = None):
|
||||||
print('\nLicense:')
|
_note('\n### License ###\n', CLR_INFO)
|
||||||
repo_licensed = False
|
repo_licensed = False
|
||||||
if clone_address:
|
if clone_address:
|
||||||
repo_licensed = _check_license_github_api(clone_address)
|
repo_licensed = _check_license_github_api(clone_address)
|
||||||
|
@ -267,15 +267,15 @@ def check_license(recipe_files: list, elisp_dir: str, clone_address: str = None)
|
||||||
repo_licensed = _check_license_file(elisp_dir)
|
repo_licensed = _check_license_file(elisp_dir)
|
||||||
individual_files_licensed = _check_license_in_files(recipe_files)
|
individual_files_licensed = _check_license_in_files(recipe_files)
|
||||||
if not repo_licensed and not individual_files_licensed:
|
if not repo_licensed and not individual_files_licensed:
|
||||||
_fail('- Use a GPL-compatible license:', CLR_ERR)
|
_fail('- Use a GPL-compatible license.')
|
||||||
print(
|
print(
|
||||||
' https://www.gnu.org/licenses/license-list.en.html#GPLCompatibleLicenses'
|
' See: https://www.gnu.org/licenses/license-list.en.html#GPLCompatibleLicenses'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _check_license_github_api(clone_address: str) -> bool:
|
def _check_license_github_api(clone_address: str) -> bool:
|
||||||
# TODO: gitlab also has a license API -- support it?
|
# TODO: gitlab also has a license API -- support it?
|
||||||
match = re.search(r'github.com/([^"]*)', clone_address)
|
match = re.search(r'github.com/([^"]*)', clone_address, flags=re.I)
|
||||||
if not match:
|
if not match:
|
||||||
return False
|
return False
|
||||||
repo_suffix = match.groups()[0].strip('/')
|
repo_suffix = match.groups()[0].strip('/')
|
||||||
|
@ -284,7 +284,7 @@ def _check_license_github_api(clone_address: str) -> bool:
|
||||||
print(f"- GitHub API found `{license_.get('name')}`")
|
print(f"- GitHub API found `{license_.get('name')}`")
|
||||||
return True
|
return True
|
||||||
if license_:
|
if license_:
|
||||||
print(f"- {CLR_WARN}GitHub API found `{license_.get('name')}`{CLR_OFF}")
|
_note(f"- GitHub API found `{license_.get('name')}`", CLR_WARN)
|
||||||
if license_.get('name') == 'Other':
|
if license_.get('name') == 'Other':
|
||||||
_fail(' - Use a GitHub-compatible format for your license file.')
|
_fail(' - Use a GitHub-compatible format for your license file.')
|
||||||
print(' See: https://github.com/licensee/licensee')
|
print(' See: https://github.com/licensee/licensee')
|
||||||
|
@ -315,7 +315,7 @@ def _check_license_in_files(elisp_files: list) -> bool:
|
||||||
_fail(f"- {basename} has no detectable license text")
|
_fail(f"- {basename} has no detectable license text")
|
||||||
individual_files_licensed = False
|
individual_files_licensed = False
|
||||||
else:
|
else:
|
||||||
_note(f"- {basename} has {license_} license text", CLR_INFO)
|
print(f"- {basename} has {license_} license text")
|
||||||
return individual_files_licensed
|
return individual_files_licensed
|
||||||
|
|
||||||
|
|
||||||
|
@ -339,9 +339,9 @@ def _check_license_in_file(elisp_file: str) -> str:
|
||||||
|
|
||||||
def check_packaging(recipe_files: list, recipe: str):
|
def check_packaging(recipe_files: list, recipe: str):
|
||||||
if ':branch "master"' in recipe:
|
if ':branch "master"' in recipe:
|
||||||
_fail('- No need to specify `:branch "master"` in recipe', CLR_ERR)
|
_fail('- No need to specify `:branch "master"` in recipe')
|
||||||
if 'gitlab' in recipe and (':repo' not in recipe or ':url' in recipe):
|
if 'gitlab' in recipe and (':repo' not in recipe or ':url' in recipe):
|
||||||
_fail('- With the GitLab fetcher you MUST set :repo and you MUST NOT set :url}')
|
_fail('- With the GitLab fetcher you MUST set :repo and you MUST NOT set :url')
|
||||||
# MELPA looks for a -pkg.el file and if it finds it, it uses that. It is
|
# MELPA looks for a -pkg.el file and if it finds it, it uses that. It is
|
||||||
# okay to have a -pkg.el file, but doing it incorrectly can break the build:
|
# okay to have a -pkg.el file, but doing it incorrectly can break the build:
|
||||||
for pkg_file in (el for el in recipe_files if el.endswith('-pkg.el')):
|
for pkg_file in (el for el in recipe_files if el.endswith('-pkg.el')):
|
||||||
|
@ -366,7 +366,7 @@ def check_packaging(recipe_files: list, recipe: str):
|
||||||
def print_details(
|
def print_details(
|
||||||
recipe: str, recipe_files: list, pr_data: dict = None, clone_address: str = None
|
recipe: str, recipe_files: list, pr_data: dict = None, clone_address: str = None
|
||||||
):
|
):
|
||||||
print('\nDetails:')
|
_note('\n### Details ###\n', CLR_INFO)
|
||||||
print(f"- `{recipe}`")
|
print(f"- `{recipe}`")
|
||||||
if ':files' in recipe:
|
if ':files' in recipe:
|
||||||
_note(' - Try to simply use the default recipe if possible', CLR_WARN)
|
_note(' - Try to simply use the default recipe if possible', CLR_WARN)
|
||||||
|
@ -394,7 +394,7 @@ def print_details(
|
||||||
# Check the maintainer
|
# Check the maintainer
|
||||||
print(f"- PR by {pr_data['user']['login']}: {clone_address}")
|
print(f"- PR by {pr_data['user']['login']}: {clone_address}")
|
||||||
if pr_data['user']['login'].lower() not in clone_address.lower():
|
if pr_data['user']['login'].lower() not in clone_address.lower():
|
||||||
print(f" - {CLR_WARN}NOTE: Repo and recipe owner don't match{CLR_OFF}")
|
_note(" - NOTE: Repo and recipe owner don't match", CLR_WARN)
|
||||||
if int(pr_data['changed_files']) != 1:
|
if int(pr_data['changed_files']) != 1:
|
||||||
_fail(' - Please only add one recipe per pull request')
|
_fail(' - Please only add one recipe per pull request')
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ def print_related_packages(recipe: str):
|
||||||
if package_tokens & other_package_tokens
|
if package_tokens & other_package_tokens
|
||||||
]
|
]
|
||||||
if related_packages:
|
if related_packages:
|
||||||
print('\nPossibly related packages:')
|
_note('\n### Similarly named packages ###\n', CLR_INFO)
|
||||||
print('\n'.join(related_packages[:5]))
|
print('\n'.join(related_packages[:5]))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue