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

Commit8232b17

Browse files
author
Ruben DI BATTISTA
committed
fix: Allow adding PathLike object to index
Close#1382
1 parent38e9a18 commit8232b17

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

‎git/index/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,11 +617,11 @@ def _preprocess_add_items(
617617
paths= []
618618
entries= []
619619
# if it is a string put in list
620-
ifisinstance(items,str):
620+
ifisinstance(items,(str,os.PathLike)):
621621
items= [items]
622622

623623
foriteminitems:
624-
ifisinstance(item,str):
624+
ifisinstance(item,(str,os.PathLike)):
625625
paths.append(self._to_relative_path(item))
626626
elifisinstance(item, (Blob,Submodule)):
627627
entries.append(BaseIndexEntry.from_blob(item))

‎test/test_index.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
importos.pathasosp
3838
fromgit.cmdimportGit
3939

40+
frompathlibimportPath
41+
4042
HOOKS_SHEBANG="#!/usr/bin/env sh\n"
4143

4244
is_win_without_bash=is_winandnotshutil.which("bash.exe")
@@ -943,3 +945,12 @@ def test_commit_msg_hook_fail(self, rw_repo):
943945
assertstr(err)
944946
else:
945947
raiseAssertionError("Should have caught a HookExecutionError")
948+
949+
@with_rw_repo('HEAD')
950+
deftest_index_add_pathlike(self,rw_repo):
951+
git_dir=Path(rw_repo.git_dir)
952+
953+
file=git_dir/"file.txt"
954+
file.touch()
955+
956+
rw_repo.index.add(file)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp