Skip to content

Commit

Permalink
As string is iterable, changed to isinstance check
Browse files Browse the repository at this point in the history
test now works
  • Loading branch information
MarcelBeining authored and Byron committed Oct 15, 2019
1 parent 1fa1ce2 commit d759e17
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ nbproject
/*egg-info
/.tox
/.vscode/
.idea/
.cache/
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "gitdb"]
url = https://github.com/gitpython-developers/gitdb.git
path = git/ext/gitdb
[submodule "gitdb"]
url = https://github.com/gitpython-developers/gitdb.git
path = git/ext/gitdb
12 changes: 4 additions & 8 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,8 @@ def _preprocess_add_items(self, items):
""" Split the items into two lists of path strings and BaseEntries. """
paths = []
entries = []
# check if is iterable, else put in list
try:
test_item = iter(items)
except TypeError:
# if it is a string put in list
if isinstance(items, str):
items = [items]

for item in items:
Expand Down Expand Up @@ -806,10 +804,8 @@ def _items_to_rela_paths(self, items):
"""Returns a list of repo-relative paths from the given items which
may be absolute or relative paths, entries or blobs"""
paths = []
# check if is iterable, else put in list
try:
test_item = iter(items)
except TypeError:
# if string put in list
if isinstance(items, str):
items = [items]

for item in items:
Expand Down
8 changes: 5 additions & 3 deletions git/test/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,11 @@ def test_compare_write_tree(self, rw_repo):

@with_rw_repo('HEAD', bare=False)
def test_index_single_addremove(self, rw_repo):
path = osp.join('git', 'test', 'test_index.py')
self._assert_entries(rw_repo.index.add(path))
deleted_files = rw_repo.index.remove(path)
fp = osp.join(rw_repo.working_dir, 'testfile.txt')
with open(fp, 'w') as fs:
fs.write(u'content of testfile')
self._assert_entries(rw_repo.index.add(fp))
deleted_files = rw_repo.index.remove(fp)
assert deleted_files

def test_index_new(self):
Expand Down

0 comments on commit d759e17

Please sign in to comment.