diff --git a/commodore/gitrepo/__init__.py b/commodore/gitrepo/__init__.py index 82e79a9d2..0ec5f331e 100644 --- a/commodore/gitrepo/__init__.py +++ b/commodore/gitrepo/__init__.py @@ -507,16 +507,20 @@ def _compute_changed_files( # `untracked_files` respects the repo's `.gitignore`. to_add = self._repo.untracked_files # We don't want to remove anything by default. - to_remove = [] + to_remove: list[str] = [] # Determine changes to stage, separated into removals and other changes changes = self._repo.index.diff(None) if changes: for c in changes: - if c.change_type == "D" or c.deleted_file: + if (c.change_type == "D" or c.deleted_file) and c.b_path: + # NOTE(sg): c.b_path is never None for deletions, but mypy doesn't understand + # that, so we make it explicit with `and c.b_path`. # Track removed files for `index.remove()` to_remove.append(c.b_path) - else: + elif c.a_path: + # NOTE(sg): c.a_path is never None for changes that aren't deletions, but mypy + # doesn't understand that, so we make it explicit with `elif c.a_path`. # Track changes which aren't deletions for `index.add()` to_add.append(c.a_path) diff --git a/poetry.lock b/poetry.lock index 162026199..4ac0b41a6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -772,20 +772,20 @@ smmap = ">=3.0.1,<6" [[package]] name = "gitpython" -version = "3.1.43" +version = "3.1.44" description = "GitPython is a Python library used to interact with Git repositories" optional = false python-versions = ">=3.7" files = [ - {file = "GitPython-3.1.43-py3-none-any.whl", hash = "sha256:eec7ec56b92aad751f9912a73404bc02ba212a23adb2c7098ee668417051a1ff"}, - {file = "GitPython-3.1.43.tar.gz", hash = "sha256:35f314a9f878467f5453cc1fee295c3e18e52f1b99f10f6cf5b1682e968a9e7c"}, + {file = "GitPython-3.1.44-py3-none-any.whl", hash = "sha256:9e0e10cda9bed1ee64bc9a6de50e7e38a9c9943241cd7f585f6df3ed28011110"}, + {file = "gitpython-3.1.44.tar.gz", hash = "sha256:c87e30b26253bf5418b01b0660f818967f3c503193838337fe5e573331249269"}, ] [package.dependencies] gitdb = ">=4.0.1,<5" [package.extras] -doc = ["sphinx (==4.3.2)", "sphinx-autodoc-typehints", "sphinx-rtd-theme", "sphinxcontrib-applehelp (>=1.0.2,<=1.0.4)", "sphinxcontrib-devhelp (==1.0.2)", "sphinxcontrib-htmlhelp (>=2.0.0,<=2.0.1)", "sphinxcontrib-qthelp (==1.0.3)", "sphinxcontrib-serializinghtml (==1.1.5)"] +doc = ["sphinx (>=7.1.2,<7.2)", "sphinx-autodoc-typehints", "sphinx_rtd_theme"] test = ["coverage[toml]", "ddt (>=1.1.1,!=1.4.3)", "mock", "mypy", "pre-commit", "pytest (>=7.3.1)", "pytest-cov", "pytest-instafail", "pytest-mock", "pytest-sugar", "typing-extensions"] [[package]] @@ -2868,4 +2868,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = ">=3.10, <3.13" -content-hash = "2ada39055688d62df8155390507468f0b500fa130a69a57f5a639be2650184f5" +content-hash = "fffcb11ac00fb4a0dca831d7c191508a02cf6ec606722e3b0efd1cf5c906d204" diff --git a/pyproject.toml b/pyproject.toml index 8c918343a..1ac4379d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,8 +32,7 @@ boto3 = "^1.26.145" botocore="^1.29.145" kapitan = "0.34.2" click = "8.1.8" -# Kapitan requires exactly 3.1.30 -gitpython = "3.1.43" +gitpython = "3.1.44" requests = "2.32.3" url-normalize = "1.4.3" python-dotenv = "1.0.1"