From 1c88b0a734142cfc05114ad2ca0794c565294fb9 Mon Sep 17 00:00:00 2001 From: jirka Date: Tue, 7 May 2024 19:32:10 +0200 Subject: [PATCH 1/4] use codespell --- .pre-commit-config.yaml | 6 ++++++ pyproject.toml | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 551d8be34..23272bc25 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,10 @@ repos: +- repo: https://github.com/codespell-project/codespell + rev: v2.2.4 + hooks: + - id: codespell + additional_dependencies: [tomli] + - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.4.3 hooks: diff --git a/pyproject.toml b/pyproject.toml index ee54edb78..7fc809a6d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,3 +78,8 @@ lint.unfixable = [ "test/**" = [ "B018", # useless-expression ] + +[tool.codespell] +#skip = '*.po,*.ts,./src/3rdParty,./src/Test' +#count = true +quiet-level = 3 \ No newline at end of file From 2ce013cc0043f7968f126ea38482a32077efa991 Mon Sep 17 00:00:00 2001 From: Jirka Date: Tue, 7 May 2024 19:38:44 +0200 Subject: [PATCH 2/4] fix & skip --- .pre-commit-config.yaml | 1 + git/index/base.py | 2 +- git/remote.py | 2 +- pyproject.toml | 3 ++- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 23272bc25..03730febd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,6 +4,7 @@ repos: hooks: - id: codespell additional_dependencies: [tomli] + args: ["--write-changes"] - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.4.3 diff --git a/git/index/base.py b/git/index/base.py index 28b60a880..a317e71c0 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -1443,7 +1443,7 @@ def reset( key = entry_key(path, 0) self.entries[key] = nie[key] except KeyError: - # If key is not in theirs, it musn't be in ours. + # If key is not in theirs, it mustn't be in ours. try: del self.entries[key] except KeyError: diff --git a/git/remote.py b/git/remote.py index 15e360064..1e09e210e 100644 --- a/git/remote.py +++ b/git/remote.py @@ -250,7 +250,7 @@ def _from_line(cls, remote: "Remote", line: str) -> "PushInfo": flags |= cls.NEW_TAG elif "[new branch]" in summary: flags |= cls.NEW_HEAD - # uptodate encoded in control character + # up-to-date encoded in control character else: # Fast-forward or forced update - was encoded in control character, # but we parse the old and new commit. diff --git a/pyproject.toml b/pyproject.toml index 7fc809a6d..8b4522824 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,6 +80,7 @@ lint.unfixable = [ ] [tool.codespell] -#skip = '*.po,*.ts,./src/3rdParty,./src/Test' +skip = 'test/fixtures/reflog_*' +ignore-words-list="gud,doesnt" #count = true quiet-level = 3 \ No newline at end of file From 93993b201458fd18059e97fa25a08a14fae2af1f Mon Sep 17 00:00:00 2001 From: jirka Date: Wed, 17 Jul 2024 12:31:02 +0200 Subject: [PATCH 3/4] fixing --- .pre-commit-config.yaml | 3 ++- README.md | 2 +- doc/source/changes.rst | 2 +- git/objects/util.py | 6 +++--- pyproject.toml | 3 +-- test/test_exc.py | 2 +- test/test_index.py | 6 +++--- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 03730febd..692c7fa2a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,8 @@ repos: hooks: - id: codespell additional_dependencies: [tomli] - args: ["--write-changes"] + # args: ["--write-changes"] # consider enabling for auto-fif + exclude: "test/fixtures/" - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.4.3 diff --git a/README.md b/README.md index d365a6584..59c6f995b 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ In the less common case that you do not want to install test dependencies, `pip #### With editable *dependencies* (not preferred, and rarely needed) -In rare cases, you may want to work on GitPython and one or both of its [gitdb](https://github.com/gitpython-developers/gitdb) and [smmap](https://github.com/gitpython-developers/smmap) dependencies at the same time, with changes in your local working copy of gitdb or smmap immediatley reflected in the behavior of your local working copy of GitPython. This can be done by making editable installations of those dependencies in the same virtual environment where you install GitPython. +In rare cases, you may want to work on GitPython and one or both of its [gitdb](https://github.com/gitpython-developers/gitdb) and [smmap](https://github.com/gitpython-developers/smmap) dependencies at the same time, with changes in your local working copy of gitdb or smmap immediately reflected in the behavior of your local working copy of GitPython. This can be done by making editable installations of those dependencies in the same virtual environment where you install GitPython. If you want to do that *and* you want the versions in GitPython's git submodules to be used, then pass `-e git/ext/gitdb` and/or `-e git/ext/gitdb/gitdb/ext/smmap` to `pip install`. This can be done in any order, and in separate `pip install` commands or the same one, so long as `-e` appears before *each* path. For example, you can install GitPython, gitdb, and smmap editably in the currently active virtual environment this way: diff --git a/doc/source/changes.rst b/doc/source/changes.rst index 0bc757134..3c903423c 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -20,7 +20,7 @@ https://github.com/gitpython-developers/GitPython/releases/tag/3.1.42 3.1.41 ====== -This release is relevant for security as it fixes a possible arbitary +This release is relevant for security as it fixes a possible arbitrary code execution on Windows. See this PR for details: https://github.com/gitpython-developers/GitPython/pull/1792 diff --git a/git/objects/util.py b/git/objects/util.py index 5c56e6134..a68d701f5 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -568,11 +568,11 @@ def addToStack( yield rval # Only continue to next level if this is appropriate! - nd = d + 1 - if depth > -1 and nd > depth: + next_d = d + 1 + if depth > -1 and next_d > depth: continue - addToStack(stack, item, branch_first, nd) + addToStack(stack, item, branch_first, next_d) # END for each item on work stack diff --git a/pyproject.toml b/pyproject.toml index 8b4522824..603e2597c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,6 @@ lint.unfixable = [ ] [tool.codespell] -skip = 'test/fixtures/reflog_*' ignore-words-list="gud,doesnt" #count = true -quiet-level = 3 \ No newline at end of file +quiet-level = 3 diff --git a/test/test_exc.py b/test/test_exc.py index c1eae7240..2e979f5a1 100644 --- a/test/test_exc.py +++ b/test/test_exc.py @@ -52,7 +52,7 @@ _streams_n_substrings = ( None, - "steram", + "stream", "ομορφο stream", ) diff --git a/test/test_index.py b/test/test_index.py index b92258c92..2684cfd81 100644 --- a/test/test_index.py +++ b/test/test_index.py @@ -1018,7 +1018,7 @@ class Mocked: @pytest.mark.xfail( type(_win_bash_status) is WinBashStatus.Absent, reason="Can't run a hook on Windows without bash.exe.", - rasies=HookExecutionError, + raises=HookExecutionError, ) @pytest.mark.xfail( type(_win_bash_status) is WinBashStatus.WslNoDistro, @@ -1077,7 +1077,7 @@ def test_hook_uses_shell_not_from_cwd(self, rw_dir, case): @pytest.mark.xfail( type(_win_bash_status) is WinBashStatus.Absent, reason="Can't run a hook on Windows without bash.exe.", - rasies=HookExecutionError, + raises=HookExecutionError, ) @pytest.mark.xfail( type(_win_bash_status) is WinBashStatus.WslNoDistro, @@ -1120,7 +1120,7 @@ def test_pre_commit_hook_fail(self, rw_repo): @pytest.mark.xfail( type(_win_bash_status) is WinBashStatus.Absent, reason="Can't run a hook on Windows without bash.exe.", - rasies=HookExecutionError, + raises=HookExecutionError, ) @pytest.mark.xfail( type(_win_bash_status) is WinBashStatus.Wsl, From 813520c123d44a8cf87a219fc710faeb1f1559ca Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:34:14 +0200 Subject: [PATCH 4/4] Apply suggestions from code review --- git/remote.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/remote.py b/git/remote.py index 1e09e210e..9de3dace4 100644 --- a/git/remote.py +++ b/git/remote.py @@ -250,7 +250,7 @@ def _from_line(cls, remote: "Remote", line: str) -> "PushInfo": flags |= cls.NEW_TAG elif "[new branch]" in summary: flags |= cls.NEW_HEAD - # up-to-date encoded in control character + # `uptodate` encoded in control character else: # Fast-forward or forced update - was encoded in control character, # but we parse the old and new commit.