Skip to content

Commit

Permalink
BREAK: remove GitPod configuration by default (#387)
Browse files Browse the repository at this point in the history
* BEHAVIOR: remove GitPod by default
* BREAK: remove `--no-gitpod` option
* ENH: remove GitPod badge and config simultaneously
  • Loading branch information
redeboer authored Sep 5, 2024
1 parent f6beb7c commit 7189c89
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ repos:
args:
- --allow-labels
- --dependabot=update
- --no-gitpod
- --no-notebooks
- --no-prettierrc
- --no-pypi
Expand Down
15 changes: 8 additions & 7 deletions src/compwa_policy/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -223,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",
Expand Down
20 changes: 13 additions & 7 deletions src/compwa_policy/check_dev_files/gitpod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -16,13 +17,11 @@
from compwa_policy.utilities.yaml import write_yaml


def main(no_gitpod: bool, python_version: PythonVersion) -> None:
if no_gitpod:
if CONFIG_PATH.gitpod.exists():
os.remove(CONFIG_PATH.gitpod)
msg = f"Removed {CONFIG_PATH.gitpod} as requested by --no-gitpod"
raise PrecommitError(msg)
remove_badge(r"\[!\[GitPod\]\(https://img.shields.io/badge/gitpod")
def main(use_gitpod: bool, python_version: PythonVersion) -> None:
if not use_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)
Expand All @@ -46,6 +45,13 @@ def main(no_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:
Expand Down

0 comments on commit 7189c89

Please sign in to comment.