Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit11839ab

Browse files
authored
Merge pull request#1648 from EliahKagan/file-protocol
Only make config more permissive in tests that need it
2 parents74e55ee +f6c3262 commit11839ab

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

‎.github/workflows/cygwin-test.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
SHELLOPTS:igncr
1313
TMP:"/tmp"
1414
TEMP:"/tmp"
15-
15+
1616
steps:
1717
-name:Force LF line endings
1818
run:git config --global core.autocrlf input
@@ -24,9 +24,8 @@ jobs:
2424
packages:python39 python39-pip python39-virtualenv git
2525
-name:Tell git to trust this repo
2626
shell:bash.exe -eo pipefail -o igncr "{0}"
27-
run:|
28-
/usr/bin/git config --global --add safe.directory $(pwd)
29-
/usr/bin/git config --global protocol.file.allow always
27+
run:|
28+
/usr/bin/git config --global --add safe.directory "$(pwd)"
3029
-name:Install dependencies and prepare tests
3130
shell:bash.exe -eo pipefail -o igncr "{0}"
3231
run:|

‎.github/workflows/pythonpackage.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ jobs:
5252
set -x
5353
mypy -p git
5454
55-
-name:Tell git to trust this repo
56-
run:|
57-
/usr/bin/git config --global --add safe.directory $(pwd)
58-
/usr/bin/git config --global protocol.file.allow always
59-
6055
-name:Test with pytest
6156
run:|
6257
set -x

‎test/test_submodule.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# -*- coding: utf-8 -*-
22
# This module is part of GitPython and is released under
33
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
4+
importcontextlib
45
importos
56
importshutil
67
importtempfile
78
frompathlibimportPath
89
importsys
9-
fromunittestimportskipIf
10+
fromunittestimportmock,skipIf
1011

1112
importpytest
1213

@@ -31,6 +32,23 @@
3132
importos.pathasosp
3233

3334

35+
@contextlib.contextmanager
36+
def_patch_git_config(name,value):
37+
"""Temporarily add a git config name-value pair, using environment variables."""
38+
pair_index=int(os.getenv("GIT_CONFIG_COUNT","0"))
39+
40+
# This is recomputed each time the context is entered, for compatibility with
41+
# existing GIT_CONFIG_* environment variables, even if changed in this process.
42+
patcher=mock.patch.dict(os.environ, {
43+
"GIT_CONFIG_COUNT":str(pair_index+1),
44+
f"GIT_CONFIG_KEY_{pair_index}":name,
45+
f"GIT_CONFIG_VALUE_{pair_index}":value,
46+
})
47+
48+
withpatcher:
49+
yield
50+
51+
3452
classTestRootProgress(RootUpdateProgress):
3553
"""Just prints messages, for now without checking the correctness of the states"""
3654

@@ -709,6 +727,7 @@ def test_add_empty_repo(self, rwdir):
709727
# end for each checkout mode
710728

711729
@with_rw_directory
730+
@_patch_git_config("protocol.file.allow","always")
712731
deftest_list_only_valid_submodules(self,rwdir):
713732
repo_path=osp.join(rwdir,"parent")
714733
repo=git.Repo.init(repo_path)
@@ -737,6 +756,7 @@ def test_list_only_valid_submodules(self, rwdir):
737756
""",
738757
)
739758
@with_rw_directory
759+
@_patch_git_config("protocol.file.allow","always")
740760
deftest_git_submodules_and_add_sm_with_new_commit(self,rwdir):
741761
parent=git.Repo.init(osp.join(rwdir,"parent"))
742762
parent.git.submodule("add",self._small_repo_url(),"module")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp