From 25512e454fdf98feb970971504a474bf54d06587 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Thu, 5 Sep 2024 21:35:12 +0200 Subject: [PATCH 1/3] BEHAVIOR: remove GitPod by default --- src/compwa_policy/check_dev_files/__init__.py | 9 ++++++++- src/compwa_policy/check_dev_files/gitpod.py | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/compwa_policy/check_dev_files/__init__.py b/src/compwa_policy/check_dev_files/__init__.py index 959e357c..d8121942 100644 --- a/src/compwa_policy/check_dev_files/__init__.py +++ b/src/compwa_policy/check_dev_files/__init__.py @@ -52,6 +52,7 @@ def main(argv: Sequence[str] | None = None) -> int: if not args.repo_title: args.repo_title = args.repo_name has_notebooks = not args.no_notebooks + use_gitpod = args.gitpod dev_python_version = __get_python_version(args.dev_python_version) package_managers: set[conda.PackageManagerChoice] = set( _to_list(args.package_managers) # type: ignore[arg-type] @@ -120,7 +121,7 @@ def main(argv: Sequence[str] | None = None) -> int: do(readthedocs.main, dev_python_version) do(remove_deprecated_tools, precommit_config, args.keep_issue_templates) do(vscode.main, has_notebooks) - do(gitpod.main, args.no_gitpod, dev_python_version) + do(gitpod.main, use_gitpod, dev_python_version) do(precommit.main, precommit_config, has_notebooks) do(tox.main, has_notebooks) do(cspell.main, precommit_config, args.no_cspell_update) @@ -178,6 +179,12 @@ def _create_argparse() -> ArgumentParser: default=False, help="Host documentation on GitHub Pages", ) + parser.add_argument( + "--gitpod", + action="store_true", + default=False, + help="Create a GitPod config file", + ) parser.add_argument( "--keep-issue-templates", help="Do not remove the .github/ISSUE_TEMPLATE directory", diff --git a/src/compwa_policy/check_dev_files/gitpod.py b/src/compwa_policy/check_dev_files/gitpod.py index e6331716..23b76b88 100644 --- a/src/compwa_policy/check_dev_files/gitpod.py +++ b/src/compwa_policy/check_dev_files/gitpod.py @@ -16,11 +16,11 @@ from compwa_policy.utilities.yaml import write_yaml -def main(no_gitpod: bool, python_version: PythonVersion) -> None: - if no_gitpod: +def main(use_gitpod: bool, python_version: PythonVersion) -> None: + if not use_gitpod: if CONFIG_PATH.gitpod.exists(): os.remove(CONFIG_PATH.gitpod) - msg = f"Removed {CONFIG_PATH.gitpod} as requested by --no-gitpod" + msg = f"Removed {CONFIG_PATH.gitpod} (add back by setting --gitpod)" raise PrecommitError(msg) remove_badge(r"\[!\[GitPod\]\(https://img.shields.io/badge/gitpod") return From 98352769527a20eb511ad5f4d25aa7921d78da72 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Thu, 5 Sep 2024 21:35:13 +0200 Subject: [PATCH 2/3] ENH: remove GitPod badge and config simultaneously --- src/compwa_policy/check_dev_files/gitpod.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/compwa_policy/check_dev_files/gitpod.py b/src/compwa_policy/check_dev_files/gitpod.py index 23b76b88..fd5d6b89 100644 --- a/src/compwa_policy/check_dev_files/gitpod.py +++ b/src/compwa_policy/check_dev_files/gitpod.py @@ -7,6 +7,7 @@ from compwa_policy.errors import PrecommitError from compwa_policy.utilities import COMPWA_POLICY_DIR, CONFIG_PATH +from compwa_policy.utilities.executor import Executor from compwa_policy.utilities.pyproject import ( Pyproject, PythonVersion, @@ -18,11 +19,9 @@ def main(use_gitpod: bool, python_version: PythonVersion) -> None: if not use_gitpod: - if CONFIG_PATH.gitpod.exists(): - os.remove(CONFIG_PATH.gitpod) - msg = f"Removed {CONFIG_PATH.gitpod} (add back by setting --gitpod)" - raise PrecommitError(msg) - remove_badge(r"\[!\[GitPod\]\(https://img.shields.io/badge/gitpod") + with Executor() as do: + do(remove_gitpod_config) + do(remove_badge, r"\[!\[GitPod\]\(https://img.shields.io/badge/gitpod") return error_message = "" expected_config = _generate_gitpod_config(python_version) @@ -46,6 +45,13 @@ def main(use_gitpod: bool, python_version: PythonVersion) -> None: pass +def remove_gitpod_config() -> None: + if CONFIG_PATH.gitpod.exists(): + os.remove(CONFIG_PATH.gitpod) + msg = f"Removed {CONFIG_PATH.gitpod} (add back by setting --gitpod)" + raise PrecommitError(msg) + + def _extract_extensions() -> dict: if CONFIG_PATH.vscode_extensions.exists(): with open(CONFIG_PATH.vscode_extensions) as stream: From 558381cb096773956f3c3a5ee07f179f49eca958 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Thu, 5 Sep 2024 21:35:13 +0200 Subject: [PATCH 3/3] BREAK: remove `--no-gitpod` option --- .pre-commit-config.yaml | 1 - src/compwa_policy/check_dev_files/__init__.py | 6 ------ 2 files changed, 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1ce01b79..23d67b37 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,7 +50,6 @@ repos: args: - --allow-labels - --dependabot=update - - --no-gitpod - --no-notebooks - --no-prettierrc - --no-pypi diff --git a/src/compwa_policy/check_dev_files/__init__.py b/src/compwa_policy/check_dev_files/__init__.py index d8121942..3bec606d 100644 --- a/src/compwa_policy/check_dev_files/__init__.py +++ b/src/compwa_policy/check_dev_files/__init__.py @@ -230,12 +230,6 @@ def _create_argparse() -> ArgumentParser: default=False, help="Skip check that concern config files for Python projects.", ) - parser.add_argument( - "--no-gitpod", - action="store_true", - default=False, - help="Do not create a GitPod config file", - ) parser.add_argument( "--no-prettierrc", action="store_true",