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

Commitcc92d51

Browse files
authored
Merge pull request#1545 from Lightborne/fix_ignored
Fix ignored
2 parentsf594266 +df4dabb commitcc92d51

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

‎git/repo/base.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,15 @@ def ignored(self, *paths: PathLike) -> List[str]:
873873
"""
874874
try:
875875
proc:str=self.git.check_ignore(*paths)
876-
exceptGitCommandError:
877-
return []
876+
exceptGitCommandErroraserr:
877+
# If return code is 1, this means none of the items in *paths
878+
# are ignored by Git, so return an empty list. Raise the
879+
# exception on all other return codes.
880+
iferr.status==1:
881+
return []
882+
else:
883+
raise
884+
878885
returnproc.replace("\\\\","\\").replace('"',"").split("\n")
879886

880887
@property

‎test/test_repo.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,3 +1384,30 @@ def test_clone_from_command_injection(self, rw_repo):
13841384
rw_repo.clone_from(payload,temp_repo.common_dir)
13851385

13861386
assertnotunexpected_file.exists()
1387+
1388+
deftest_ignored_items_reported(self):
1389+
withtempfile.TemporaryDirectory()astdir:
1390+
tmp_dir=pathlib.Path(tdir)
1391+
temp_repo=Repo.init(tmp_dir/"repo")
1392+
1393+
gi=tmp_dir/"repo"/".gitignore"
1394+
1395+
withopen(gi,'w')asfile:
1396+
file.write('ignored_file.txt\n')
1397+
file.write('ignored_dir/\n')
1398+
1399+
asserttemp_repo.ignored(['included_file.txt','included_dir/file.txt'])== []
1400+
asserttemp_repo.ignored(['ignored_file.txt'])== ['ignored_file.txt']
1401+
asserttemp_repo.ignored(['included_file.txt','ignored_file.txt'])== ['ignored_file.txt']
1402+
asserttemp_repo.ignored(['included_file.txt','ignored_file.txt','included_dir/file.txt','ignored_dir/file.txt'])== ['ignored_file.txt','ignored_dir/file.txt']
1403+
1404+
deftest_ignored_raises_error_w_symlink(self):
1405+
withtempfile.TemporaryDirectory()astdir:
1406+
tmp_dir=pathlib.Path(tdir)
1407+
temp_repo=Repo.init(tmp_dir/"repo")
1408+
1409+
os.mkdir(tmp_dir/"target")
1410+
os.symlink(tmp_dir/"target",tmp_dir/"symlink")
1411+
1412+
withpytest.raises(GitCommandError):
1413+
temp_repo.ignored(tmp_dir/"symlink/file.txt")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp