From f2483a6151a99b7326b657fd945ec75f891e6462 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 13:53:04 +0000 Subject: [PATCH 01/25] Bump Vampire/setup-wsl from 5.0.0 to 5.0.1 Bumps [Vampire/setup-wsl](https://github.com/vampire/setup-wsl) from 5.0.0 to 5.0.1. - [Release notes](https://github.com/vampire/setup-wsl/releases) - [Commits](https://github.com/vampire/setup-wsl/compare/v5.0.0...v5.0.1) --- updated-dependencies: - dependency-name: Vampire/setup-wsl dependency-version: 5.0.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 61088237d..9fd660c6b 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -51,7 +51,7 @@ jobs: - name: Set up WSL (Windows) if: matrix.os-type == 'windows' - uses: Vampire/setup-wsl@v5.0.0 + uses: Vampire/setup-wsl@v5.0.1 with: wsl-version: 1 distribution: Alpine From ec0087227ed37cf1df441e4f0f73daa25895c4b5 Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Wed, 21 May 2025 15:48:34 -0400 Subject: [PATCH 02/25] add tests for is_cygwin_git --- test/test_util.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test_util.py b/test/test_util.py index dad2f3dcd..ed57dcbae 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -34,6 +34,7 @@ LockFile, cygpath, decygpath, + is_cygwin_git, get_user_id, remove_password_if_present, rmtree, @@ -349,6 +350,24 @@ def test_decygpath(self, wpath, cpath): assert wcpath == wpath.replace("/", "\\"), cpath +class TestIsCygwinGit: + """Tests for :func:`is_cygwin_git`""" + + def test_on_path_executable(self): + match sys.platform: + case "cygwin": + assert is_cygwin_git("git") + case _: + assert not is_cygwin_git("git") + + def test_none_executable(self): + assert not is_cygwin_git(None) + + def test_with_missing_uname(self): + """Test for handling when `uname` isn't in the same directory as `git`""" + assert not is_cygwin_git("/bogus_path/git") + + class _Member: """A member of an IterableList.""" From de5e57caf26e5f6772ac02a3944e58e0aba177f3 Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Wed, 21 May 2025 15:49:07 -0400 Subject: [PATCH 03/25] check for the existence/execute bit on the uname command before trying to run it --- git/util.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git/util.py b/git/util.py index 9e8ac821d..f1a94c469 100644 --- a/git/util.py +++ b/git/util.py @@ -463,7 +463,13 @@ def _is_cygwin_git(git_executable: str) -> bool: git_dir = osp.dirname(res[0]) if res else "" # Just a name given, not a real path. + # Let's see if the same path has uname uname_cmd = osp.join(git_dir, "uname") + if not (osp.isfile(uname_cmd) and os.access(uname_cmd, os.X_OK)): + _logger.debug(f"File {uname_cmd} either does not exist or is not executable.") + _is_cygwin_cache[git_executable] = is_cygwin + return is_cygwin + process = subprocess.Popen([uname_cmd], stdout=subprocess.PIPE, universal_newlines=True) uname_out, _ = process.communicate() # retcode = process.poll() From 428be1a504e2b30c195786d5ca6708f4c39d90a7 Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Wed, 21 May 2025 15:51:29 -0400 Subject: [PATCH 04/25] adding self to authors --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 45b14c961..b57113edd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -55,5 +55,6 @@ Contributors are: -Eliah Kagan -Ethan Lin -Jonas Scharpf +-Gordon Marx Portions derived from other open source works and are clearly marked. From 58ff723e6757af3c508e2a9424d287e5016ac230 Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Thu, 22 May 2025 08:54:42 -0400 Subject: [PATCH 05/25] Revert "check for the existence/execute bit on the uname command before trying to run it" This reverts commit de5e57caf26e5f6772ac02a3944e58e0aba177f3. --- git/util.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/git/util.py b/git/util.py index f1a94c469..9e8ac821d 100644 --- a/git/util.py +++ b/git/util.py @@ -463,13 +463,7 @@ def _is_cygwin_git(git_executable: str) -> bool: git_dir = osp.dirname(res[0]) if res else "" # Just a name given, not a real path. - # Let's see if the same path has uname uname_cmd = osp.join(git_dir, "uname") - if not (osp.isfile(uname_cmd) and os.access(uname_cmd, os.X_OK)): - _logger.debug(f"File {uname_cmd} either does not exist or is not executable.") - _is_cygwin_cache[git_executable] = is_cygwin - return is_cygwin - process = subprocess.Popen([uname_cmd], stdout=subprocess.PIPE, universal_newlines=True) uname_out, _ = process.communicate() # retcode = process.poll() From 71879840b8a72890f63fcadf7a92694106610ef0 Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Thu, 22 May 2025 09:05:13 -0400 Subject: [PATCH 06/25] use pathlib.Path instead of os.path.isfile --- git/util.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git/util.py b/git/util.py index 9e8ac821d..3b6917fc4 100644 --- a/git/util.py +++ b/git/util.py @@ -464,6 +464,12 @@ def _is_cygwin_git(git_executable: str) -> bool: # Just a name given, not a real path. uname_cmd = osp.join(git_dir, "uname") + + if not (pathlib.Path(uname_cmd).exists() and os.access(uname_cmd, os.X_OK)): + _logger.debug(f"Failed checking if running in CYGWIN: {uname_cmd} is not an executable") + _is_cygwin_cache[git_executable] = is_cygwin + return is_cygwin + process = subprocess.Popen([uname_cmd], stdout=subprocess.PIPE, universal_newlines=True) uname_out, _ = process.communicate() # retcode = process.poll() From 3f5a942be8293bb8c663631756885f877afc22e7 Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Thu, 22 May 2025 09:06:02 -0400 Subject: [PATCH 07/25] don't keep checking if sys.platform isn't 'cygwin' --- git/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/util.py b/git/util.py index 3b6917fc4..989f9196c 100644 --- a/git/util.py +++ b/git/util.py @@ -490,7 +490,7 @@ def is_cygwin_git(git_executable: PathLike) -> bool: ... def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool: - if sys.platform == "win32": # TODO: See if we can use `sys.platform != "cygwin"`. + if sys.platform != "cygwin": return False elif git_executable is None: return False From 226f4ffcaf2deed4598b9ff53902a12f6483c069 Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Thu, 22 May 2025 09:15:50 -0400 Subject: [PATCH 08/25] check that uname_cmd points to a file; if uname_cmd were a directory, it could both exist and have os.X_OK but not work --- git/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/util.py b/git/util.py index 989f9196c..32a808c60 100644 --- a/git/util.py +++ b/git/util.py @@ -465,7 +465,7 @@ def _is_cygwin_git(git_executable: str) -> bool: # Just a name given, not a real path. uname_cmd = osp.join(git_dir, "uname") - if not (pathlib.Path(uname_cmd).exists() and os.access(uname_cmd, os.X_OK)): + if not (pathlib.Path(uname_cmd).isfile() and os.access(uname_cmd, os.X_OK)): _logger.debug(f"Failed checking if running in CYGWIN: {uname_cmd} is not an executable") _is_cygwin_cache[git_executable] = is_cygwin return is_cygwin From 22d6284b099e99716da101198ce113c96e35423a Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Thu, 22 May 2025 09:24:37 -0400 Subject: [PATCH 09/25] don't use match-case, since it's a 3.10 feature --- test/test_util.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/test_util.py b/test/test_util.py index ed57dcbae..de80ca3af 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -354,11 +354,10 @@ class TestIsCygwinGit: """Tests for :func:`is_cygwin_git`""" def test_on_path_executable(self): - match sys.platform: - case "cygwin": - assert is_cygwin_git("git") - case _: - assert not is_cygwin_git("git") + if sys.platform == "cygwin": + assert is_cygwin_git("git") + else: + assert not is_cygwin_git("git") def test_none_executable(self): assert not is_cygwin_git(None) From b1289eeb3676e63f4261518655ee90808e9d3d1f Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Thu, 22 May 2025 10:56:26 -0400 Subject: [PATCH 10/25] it's is_file(), not isfile() --- git/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git/util.py b/git/util.py index 32a808c60..4071fdc14 100644 --- a/git/util.py +++ b/git/util.py @@ -465,7 +465,7 @@ def _is_cygwin_git(git_executable: str) -> bool: # Just a name given, not a real path. uname_cmd = osp.join(git_dir, "uname") - if not (pathlib.Path(uname_cmd).isfile() and os.access(uname_cmd, os.X_OK)): + if not (pathlib.Path(uname_cmd).is_file() and os.access(uname_cmd, os.X_OK)): _logger.debug(f"Failed checking if running in CYGWIN: {uname_cmd} is not an executable") _is_cygwin_cache[git_executable] = is_cygwin return is_cygwin @@ -490,6 +490,7 @@ def is_cygwin_git(git_executable: PathLike) -> bool: ... def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool: + _logger.debug(f"{sys.platform=}, {git_executable=}") if sys.platform != "cygwin": return False elif git_executable is None: From cffa264bdc1dd09a13a85cc27417b85628273e14 Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Thu, 22 May 2025 11:11:48 -0400 Subject: [PATCH 11/25] turns out f-strings before 3.8 don't support {variable=} notation, take that out --- git/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/util.py b/git/util.py index 4071fdc14..66175ea33 100644 --- a/git/util.py +++ b/git/util.py @@ -490,7 +490,7 @@ def is_cygwin_git(git_executable: PathLike) -> bool: ... def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool: - _logger.debug(f"{sys.platform=}, {git_executable=}") + _logger.debug(f"sys.platform = {sys.platform}, git_executable = {git_executable}") if sys.platform != "cygwin": return False elif git_executable is None: From 8dc75521bd42db19d41e8d92ce5204dfe1a594ac Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Thu, 22 May 2025 15:48:54 -0400 Subject: [PATCH 12/25] remove type assertions from util.py --- git/util.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/git/util.py b/git/util.py index 9e8ac821d..0d09c3f09 100644 --- a/git/util.py +++ b/git/util.py @@ -1200,8 +1200,6 @@ def __getattr__(self, attr: str) -> T_IterableObj: return list.__getattribute__(self, attr) def __getitem__(self, index: Union[SupportsIndex, int, slice, str]) -> T_IterableObj: # type: ignore[override] - assert isinstance(index, (int, str, slice)), "Index of IterableList should be an int or str" - if isinstance(index, int): return list.__getitem__(self, index) elif isinstance(index, slice): @@ -1214,8 +1212,6 @@ def __getitem__(self, index: Union[SupportsIndex, int, slice, str]) -> T_Iterabl # END handle getattr def __delitem__(self, index: Union[SupportsIndex, int, slice, str]) -> None: - assert isinstance(index, (int, str)), "Index of IterableList should be an int or str" - delindex = cast(int, index) if not isinstance(index, int): delindex = -1 From 36a893bbd47a08df80e0266f6ce5182915511833 Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Fri, 23 May 2025 07:24:43 -0400 Subject: [PATCH 13/25] add self to AUTHORS, add Emacs tempfiles to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d85569405..eab294a65 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ __pycache__/ # Transient editor files *.swp *~ +\#*# +.#*# # Editor configuration nbproject From c441316b7714207eaf2c13be5104d15ec69943bd Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Tue, 27 May 2025 10:58:24 -0400 Subject: [PATCH 14/25] use `strings` instead of `uname` to detect cygwin --- git/util.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/git/util.py b/git/util.py index 66175ea33..53475eeb3 100644 --- a/git/util.py +++ b/git/util.py @@ -457,23 +457,24 @@ def _is_cygwin_git(git_executable: str) -> bool: if is_cygwin is None: is_cygwin = False try: - git_dir = osp.dirname(git_executable) + git_cmd = pathlib.Path(git_executable) + git_dir = git_cmd.parent + if not git_dir: res = py_where(git_executable) - git_dir = osp.dirname(res[0]) if res else "" + git_dir = pathlib.Path(res[0]).parent if res else "" - # Just a name given, not a real path. - uname_cmd = osp.join(git_dir, "uname") + # If it's a cygwin git, it'll have cygwin in the output of `strings git` + strings_cmd = pathlib.Path(git_dir, "strings") - if not (pathlib.Path(uname_cmd).is_file() and os.access(uname_cmd, os.X_OK)): - _logger.debug(f"Failed checking if running in CYGWIN: {uname_cmd} is not an executable") - _is_cygwin_cache[git_executable] = is_cygwin + if not (pathlib.Path(strings_cmd).is_file() and os.access(strings_cmd, os.X_OK)): + _logger.debug(f"Failed checking if running in CYGWIN: {strings_cmd} is not an executable") + _is_cygwin_cache[git_executable] = False return is_cygwin - process = subprocess.Popen([uname_cmd], stdout=subprocess.PIPE, universal_newlines=True) - uname_out, _ = process.communicate() - # retcode = process.poll() - is_cygwin = "CYGWIN" in uname_out + process = subprocess.Popen([strings_cmd, git_cmd], stdout=subprocess.PIPE, text=True) + strings_output, _ = process.communicate() + is_cygwin = any(x for x in strings_output if "cygwin" in x.lower()) except Exception as ex: _logger.debug("Failed checking if running in CYGWIN due to: %r", ex) _is_cygwin_cache[git_executable] = is_cygwin From 0df08181f1012f0e591f998dcc57fd594e754d98 Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Tue, 27 May 2025 11:32:23 -0400 Subject: [PATCH 15/25] debug printing --- git/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git/util.py b/git/util.py index 53475eeb3..81761f15c 100644 --- a/git/util.py +++ b/git/util.py @@ -475,6 +475,8 @@ def _is_cygwin_git(git_executable: str) -> bool: process = subprocess.Popen([strings_cmd, git_cmd], stdout=subprocess.PIPE, text=True) strings_output, _ = process.communicate() is_cygwin = any(x for x in strings_output if "cygwin" in x.lower()) + if not is_cygwin: + _logger.debug(f"is not cygwin: {strings_output}") except Exception as ex: _logger.debug("Failed checking if running in CYGWIN due to: %r", ex) _is_cygwin_cache[git_executable] = is_cygwin From 58f77105f5163408a9bf323518b96646ab413561 Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Wed, 28 May 2025 11:15:06 -0400 Subject: [PATCH 16/25] Revert "debug printing" This reverts commit 0df08181f1012f0e591f998dcc57fd594e754d98. --- git/util.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/git/util.py b/git/util.py index 81761f15c..53475eeb3 100644 --- a/git/util.py +++ b/git/util.py @@ -475,8 +475,6 @@ def _is_cygwin_git(git_executable: str) -> bool: process = subprocess.Popen([strings_cmd, git_cmd], stdout=subprocess.PIPE, text=True) strings_output, _ = process.communicate() is_cygwin = any(x for x in strings_output if "cygwin" in x.lower()) - if not is_cygwin: - _logger.debug(f"is not cygwin: {strings_output}") except Exception as ex: _logger.debug("Failed checking if running in CYGWIN due to: %r", ex) _is_cygwin_cache[git_executable] = is_cygwin From 1731c1e377aca056d1a7acf2dd6df0e68a4e9e7e Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Wed, 28 May 2025 11:15:23 -0400 Subject: [PATCH 17/25] Revert "use `strings` instead of `uname` to detect cygwin" This reverts commit c441316b7714207eaf2c13be5104d15ec69943bd. --- git/util.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/git/util.py b/git/util.py index 53475eeb3..66175ea33 100644 --- a/git/util.py +++ b/git/util.py @@ -457,24 +457,23 @@ def _is_cygwin_git(git_executable: str) -> bool: if is_cygwin is None: is_cygwin = False try: - git_cmd = pathlib.Path(git_executable) - git_dir = git_cmd.parent - + git_dir = osp.dirname(git_executable) if not git_dir: res = py_where(git_executable) - git_dir = pathlib.Path(res[0]).parent if res else "" + git_dir = osp.dirname(res[0]) if res else "" - # If it's a cygwin git, it'll have cygwin in the output of `strings git` - strings_cmd = pathlib.Path(git_dir, "strings") + # Just a name given, not a real path. + uname_cmd = osp.join(git_dir, "uname") - if not (pathlib.Path(strings_cmd).is_file() and os.access(strings_cmd, os.X_OK)): - _logger.debug(f"Failed checking if running in CYGWIN: {strings_cmd} is not an executable") - _is_cygwin_cache[git_executable] = False + if not (pathlib.Path(uname_cmd).is_file() and os.access(uname_cmd, os.X_OK)): + _logger.debug(f"Failed checking if running in CYGWIN: {uname_cmd} is not an executable") + _is_cygwin_cache[git_executable] = is_cygwin return is_cygwin - process = subprocess.Popen([strings_cmd, git_cmd], stdout=subprocess.PIPE, text=True) - strings_output, _ = process.communicate() - is_cygwin = any(x for x in strings_output if "cygwin" in x.lower()) + process = subprocess.Popen([uname_cmd], stdout=subprocess.PIPE, universal_newlines=True) + uname_out, _ = process.communicate() + # retcode = process.poll() + is_cygwin = "CYGWIN" in uname_out except Exception as ex: _logger.debug("Failed checking if running in CYGWIN due to: %r", ex) _is_cygwin_cache[git_executable] = is_cygwin From f3ab5d3810b1e8c1f0365d26eea3e91808d8e4af Mon Sep 17 00:00:00 2001 From: Gordon Marx Date: Wed, 28 May 2025 11:21:28 -0400 Subject: [PATCH 18/25] incorporate review feedback from @EliahKagan --- git/util.py | 3 ++- test/test_util.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/git/util.py b/git/util.py index 66175ea33..a10609185 100644 --- a/git/util.py +++ b/git/util.py @@ -490,7 +490,8 @@ def is_cygwin_git(git_executable: PathLike) -> bool: ... def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool: - _logger.debug(f"sys.platform = {sys.platform}, git_executable = {git_executable}") + # TODO: when py3.7 support is dropped, use the new interpolation f"{variable=}" + _logger.debug(f"sys.platform={sys.platform!r}, git_executable={git_executable!r}") if sys.platform != "cygwin": return False elif git_executable is None: diff --git a/test/test_util.py b/test/test_util.py index de80ca3af..000830f41 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -354,6 +354,7 @@ class TestIsCygwinGit: """Tests for :func:`is_cygwin_git`""" def test_on_path_executable(self): + # Currently we assume tests run on Cygwin use Cygwin git. See #533 and #1455 for background. if sys.platform == "cygwin": assert is_cygwin_git("git") else: From b7ce712c631c0b59566af43e7a4b00cc1dbeba3b Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 30 May 2025 12:36:37 -0400 Subject: [PATCH 19/25] Use newer ruff style This updates `ruff` in `.pre-commit-config.yaml` from 0.6.0 to 0.11.12, changes its `id` from the legacy `ruff` alias to `ruff-check` (which is better distinguished from `ruff-format`, which we also have a hook for), and applies the few style changes it newly recommends throughout the code. The style changes seem to make things slightly clearer overall. This also updates some other pre-commit hooks, but those don't require any changes to the code. Currently the `ruff` dependency in `requirements-dev.txt` doesn't specify a version, so no change is needed there. This update may be seen as bringing the `pre-commit` version in line with what users will usually have locally with `pip install -e ".[test]"`. The `pre-commit` hooks are how linting is currently done on CI, so this is updating `ruff` for CI. That's the most significant effect of this change. (`pre-commit` is run for linting on CI probably much more often than it is used locally, to manage pre-commit hooks or otherwise, in GitPython development.) --- .pre-commit-config.yaml | 10 +++++----- git/cmd.py | 4 ++-- git/refs/log.py | 2 +- git/repo/fun.py | 2 +- test/test_git.py | 2 +- test/test_quick_doc.py | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 424cc5f37..737b56d45 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,15 +1,15 @@ repos: - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell additional_dependencies: [tomli] exclude: ^test/fixtures/ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.0 + rev: v0.11.12 hooks: - - id: ruff + - id: ruff-check args: ["--fix"] exclude: ^git/ext/ - id: ruff-format @@ -23,7 +23,7 @@ repos: exclude: ^test/fixtures/polyglot$|^git/ext/ - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: end-of-file-fixer exclude: ^test/fixtures/|COPYING|LICENSE @@ -33,6 +33,6 @@ repos: - id: check-merge-conflict - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.19 + rev: v0.24.1 hooks: - id: validate-pyproject diff --git a/git/cmd.py b/git/cmd.py index 2048a43fa..7f46edc8f 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -207,7 +207,7 @@ def pump_stream( ) if stderr_handler: error_str: Union[str, bytes] = ( - "error: process killed because it timed out." f" kill_after_timeout={kill_after_timeout} seconds" + f"error: process killed because it timed out. kill_after_timeout={kill_after_timeout} seconds" ) if not decode_streams and isinstance(p_stderr, BinaryIO): # Assume stderr_handler needs binary input. @@ -1319,7 +1319,7 @@ def communicate() -> Tuple[AnyStr, AnyStr]: out, err = proc.communicate() watchdog.cancel() if kill_check.is_set(): - err = 'Timeout: the command "%s" did not complete in %d ' "secs." % ( + err = 'Timeout: the command "%s" did not complete in %d secs.' % ( " ".join(redacted_command), timeout, ) diff --git a/git/refs/log.py b/git/refs/log.py index 17e3a94b3..8f2f2cd38 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -126,7 +126,7 @@ def from_line(cls, line: bytes) -> "RefLogEntry": elif len(fields) == 2: info, msg = fields else: - raise ValueError("Line must have up to two TAB-separated fields." " Got %s" % repr(line_str)) + raise ValueError("Line must have up to two TAB-separated fields. Got %s" % repr(line_str)) # END handle first split oldhexsha = info[:40] diff --git a/git/repo/fun.py b/git/repo/fun.py index 125ba5936..1c995c6c6 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -405,7 +405,7 @@ def rev_parse(repo: "Repo", rev: str) -> AnyGitObject: # END end handle tag except (IndexError, AttributeError) as e: raise BadName( - f"Invalid revision spec '{rev}' - not enough " f"parent commits to reach '{token}{int(num)}'" + f"Invalid revision spec '{rev}' - not enough parent commits to reach '{token}{int(num)}'" ) from e # END exception handling # END parse loop diff --git a/test/test_git.py b/test/test_git.py index 274511f8d..5bcf89bdd 100644 --- a/test/test_git.py +++ b/test/test_git.py @@ -747,7 +747,7 @@ def test_environment(self, rw_dir): path = osp.join(rw_dir, "failing-script.sh") with open(path, "wt") as stream: - stream.write("#!/usr/bin/env sh\n" "echo FOO\n") + stream.write("#!/usr/bin/env sh\necho FOO\n") os.chmod(path, 0o777) rw_repo = Repo.init(osp.join(rw_dir, "repo")) diff --git a/test/test_quick_doc.py b/test/test_quick_doc.py index 4ef75f4aa..98658e02f 100644 --- a/test/test_quick_doc.py +++ b/test/test_quick_doc.py @@ -173,7 +173,7 @@ def test_cloned_repo_object(self, local_dir): # [15-test_cloned_repo_object] def print_files_from_git(root, level=0): for entry in root: - print(f'{"-" * 4 * level}| {entry.path}, {entry.type}') + print(f"{'-' * 4 * level}| {entry.path}, {entry.type}") if entry.type == "tree": print_files_from_git(entry, level + 1) From 0c0fc7ee97c14088ef1705d756e04dadd9cfdd8a Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 30 May 2025 14:37:03 -0400 Subject: [PATCH 20/25] Temporarily remove CodeQL workflow file So GitHub can regenerate a fresh new one based on current defaults. --- .github/workflows/codeql.yml | 80 ------------------------------------ 1 file changed, 80 deletions(-) delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index ae5241898..000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,80 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - pull_request: - schedule: - - cron: '27 10 * * 3' - -jobs: - analyze: - name: Analyze - # Runner size impacts CodeQL analysis time. To learn more, please see: - # - https://gh.io/recommended-hardware-resources-for-running-codeql - # - https://gh.io/supported-runners-and-hardware-resources - # - https://gh.io/using-larger-runners - # Consider using larger runners for possible analysis time improvements. - runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} - timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'python' ] - # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] - # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both - # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - setup-python-dependencies: false - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" From 847ead6948efa5d33a8798395220ed6b719a56f2 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 30 May 2025 14:40:38 -0400 Subject: [PATCH 21/25] Recreate `codeq.yml` with current defaults This adds CodeQL scanning of GitHub Actions, while continuing to scan Python as well. This will subsequently be customized slightly to restore some elements of the preivous custom workflow that we may prefer. --- .github/workflows/codeql.yml | 100 +++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..450166503 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,100 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL Advanced" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: '36 18 * * 0' + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: actions + build-mode: none + - language: python + build-mode: none + # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Add any setup steps before running the `github/codeql-action/init` action. + # This includes steps like installing compilers or runtimes (`actions/setup-node` + # or others). This is typically only required for manual builds. + # - name: Setup runtime (example) + # uses: actions/setup-example@v1 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + - if: matrix.build-mode == 'manual' + shell: bash + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" From d7ce09fa75a7a86ed089ecff330ee86333df5200 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 30 May 2025 14:51:21 -0400 Subject: [PATCH 22/25] Keep running CodeQL on all branches, etc. This restores three aspects of the previous `codeql.yml`: - Run it on all branches, not just `main`. - Run it on the previous schedule rather than the new one, since there's no reason to change the schedule (though there's no reason to be attached to the old schedule either). - Use "CodeQL" rather than "CodeQL Advanced" as the workflow `name`, since this takes up less horizontal space when reading the reports from the checks. Of these, only the first is really significant. --- .github/workflows/codeql.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 450166503..3d273f9c7 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,15 +9,13 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL Advanced" +name: "CodeQL" on: push: - branches: [ "main" ] pull_request: - branches: [ "main" ] schedule: - - cron: '36 18 * * 0' + - cron: '27 10 * * 3' jobs: analyze: From 89dbd4a85ae78c272e5714e827f70783df04f924 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 30 May 2025 14:58:09 -0400 Subject: [PATCH 23/25] Remove unnecessary permissions from `codeql.yml` This is another change back to the way we had it before, but the removals are based specifically on the guidance in the default workflow comments about why each permission was given by default. --- .github/workflows/codeql.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 3d273f9c7..2bee952af 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -27,16 +27,8 @@ jobs: # Consider using larger runners or machines with greater resources for possible analysis time improvements. runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} permissions: - # required for all workflows security-events: write - # required to fetch internal or private CodeQL packs - packages: read - - # only required for workflows in private repositories - actions: read - contents: read - strategy: fail-fast: false matrix: From a9833d635dd5201cd94cc9d061590e41e24ea0cc Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Fri, 30 May 2025 15:38:00 -0400 Subject: [PATCH 24/25] Specify explicit `contents: read` workflow permissions Three CI workflows that need only `contents: read` permissions and no other permissions did not have explicit permissions set, and would therefore be given default permissions configured for the repository, which might be more expansive than the workflows need. It is recommended to set explicit workflow permissions [1]. This does that, specifying permissions as `pythonpackage.yml` already did, and closing three `actions/missing-workflow-permissions` CodeQL alerts (new since #2032 enabled scanning of GHA workflows). [1]: https://codeql.github.com/codeql-query-help/actions/actions-missing-workflow-permissions/ --- .github/workflows/alpine-test.yml | 3 +++ .github/workflows/cygwin-test.yml | 3 +++ .github/workflows/lint.yml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/.github/workflows/alpine-test.yml b/.github/workflows/alpine-test.yml index bd09a939b..513c65bb8 100644 --- a/.github/workflows/alpine-test.yml +++ b/.github/workflows/alpine-test.yml @@ -2,6 +2,9 @@ name: test-alpine on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + jobs: test: runs-on: ubuntu-latest diff --git a/.github/workflows/cygwin-test.yml b/.github/workflows/cygwin-test.yml index 278777907..572a9197e 100644 --- a/.github/workflows/cygwin-test.yml +++ b/.github/workflows/cygwin-test.yml @@ -2,6 +2,9 @@ name: test-cygwin on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + jobs: test: runs-on: windows-latest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a0e81a993..ceba0dd85 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,6 +2,9 @@ name: Lint on: [push, pull_request, workflow_dispatch] +permissions: + contents: read + jobs: lint: runs-on: ubuntu-latest From 00b46127e54c104ac86333150708acdccce98cb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 03:22:44 +0000 Subject: [PATCH 25/25] Bump git/ext/gitdb from `f36c0cc` to `7e02fbd` Bumps [git/ext/gitdb](https://github.com/gitpython-developers/gitdb) from `f36c0cc` to `7e02fbd`. - [Release notes](https://github.com/gitpython-developers/gitdb/releases) - [Commits](https://github.com/gitpython-developers/gitdb/compare/f36c0cc42ea2f529291e441073f74e920988d4d2...7e02fbde5fcfcd52f541995fbcde22e85535adef) --- updated-dependencies: - dependency-name: git/ext/gitdb dependency-version: 7e02fbde5fcfcd52f541995fbcde22e85535adef dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- git/ext/gitdb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/ext/gitdb b/git/ext/gitdb index f36c0cc42..335c0f661 160000 --- a/git/ext/gitdb +++ b/git/ext/gitdb @@ -1 +1 @@ -Subproject commit f36c0cc42ea2f529291e441073f74e920988d4d2 +Subproject commit 335c0f66173eecdc7b2597c2b6c3d1fde795df30