diff options
Diffstat (limited to '')
| -rw-r--r-- | .github/workflows/ci.yml | 2 | ||||
| -rw-r--r-- | cgitize/cgit.py | 2 | ||||
| -rw-r--r-- | cgitize/repo.py | 61 | ||||
| -rw-r--r-- | cgitize/utils.py | 10 | ||||
| -rw-r--r-- | pyproject.toml | 3 |
5 files changed, 36 insertions, 42 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68c0d5e..494a096 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] + python-version: ['3.11', '3.12', '3.13', '3.14'] name: 'Test / ${{ matrix.python-version }}' env: CGITIZE_GITHUB_USERNAME: '${{ secrets.CGITIZE_GITHUB_USERNAME }}' diff --git a/cgitize/cgit.py b/cgitize/cgit.py index 9e8d46d..547235c 100644 --- a/cgitize/cgit.py +++ b/cgitize/cgit.py @@ -3,12 +3,12 @@ # For details, see https://github.com/egor-tensin/cgitize # Distributed under the MIT License. +from contextlib import chdir import logging import os import shutil from cgitize.git import Git -from cgitize.utils import chdir class CGitServer: diff --git a/cgitize/repo.py b/cgitize/repo.py index f0c8400..37c9624 100644 --- a/cgitize/repo.py +++ b/cgitize/repo.py @@ -3,19 +3,16 @@ # For details, see https://github.com/egor-tensin/cgitize # Distributed under the MIT License. -from enum import Enum +from enum import auto, StrEnum import os.path from cgitize import url -class Visibility(Enum): - ALL = "all" - PUBLIC = "public" - PRIVATE = "private" - - def __str__(self): - return self.name +class Visibility(StrEnum): + ALL = auto() + PUBLIC = auto() + PRIVATE = auto() @staticmethod def from_config(public, private): @@ -32,33 +29,39 @@ class Visibility(Enum): def to_bitbucket_arg(self): # https://developer.atlassian.com/cloud/bitbucket/rest/intro/#filtering # https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-group-repositories - if self is Visibility.ALL: - return None - if self is Visibility.PUBLIC: - return "is_private=False" - if self is Visibility.PRIVATE: - return "is_private=True" - raise NotImplementedError(f"not implemented visibility level: {self}") + match self: + case Visibility.ALL: + return None + case Visibility.PUBLIC: + return "is_private=False" + case Visibility.PRIVATE: + return "is_private=True" + case _: + raise NotImplementedError(f"not implemented visibility level: {self}") def to_github_arg(self): # https://docs.github.com/en/rest/repos/repos?apiVersion=2026-03-10#list-repositories-for-the-authenticated-user - if self is Visibility.ALL: - return None - if self is Visibility.PUBLIC: - return "public" - if self is Visibility.PRIVATE: - return "private" - raise NotImplementedError(f"not implemented visibility level: {self}") + match self: + case Visibility.ALL: + return None + case Visibility.PUBLIC: + return "public" + case Visibility.PRIVATE: + return "private" + case _: + raise NotImplementedError(f"not implemented visibility level: {self}") def to_gitlab_arg(self): # https://python-gitlab.readthedocs.io/en/stable/gl_objects/projects.html#projects - if self is Visibility.ALL: - return None - if self is Visibility.PUBLIC: - return "public" - if self is Visibility.PRIVATE: - return "private" - raise NotImplementedError(f"not implemented visibility level: {self}") + match self: + case Visibility.ALL: + return None + case Visibility.PUBLIC: + return "public" + case Visibility.PRIVATE: + return "private" + case _: + raise NotImplementedError(f"not implemented visibility level: {self}") class Repo: diff --git a/cgitize/utils.py b/cgitize/utils.py index fc21d9e..6153dea 100644 --- a/cgitize/utils.py +++ b/cgitize/utils.py @@ -78,16 +78,6 @@ def try_capture(*args, **kwargs): @contextmanager -def chdir(new_cwd): - old_cwd = os.getcwd() - os.chdir(new_cwd) - try: - yield - finally: - os.chdir(old_cwd) - - -@contextmanager def protected_file(path): # 0600: new_permissions = stat.S_IRUSR | stat.S_IWUSR diff --git a/pyproject.toml b/pyproject.toml index d55624e..c73be33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,8 @@ license-files = ["LICENSE.txt"] dynamic = ["version"] authors = [{name = "Egor Tensin", email = "egor@tensin.name"}] readme = "README.md" -requires-python = ">=3.9" +requires-python = ">=3.11" +# ^^^ For enum.StrEnum/contextlib.chdir, at least? dependencies = [ "atlassian-python-api ~= 4.0", |
