Skip to content

Commit

Permalink
Merge pull request #321 from yarikoptic/bf-git-remove
Browse files Browse the repository at this point in the history
git remove -- should not match_return_type
  • Loading branch information
yarikoptic committed Dec 21, 2015
2 parents 0084ff7 + e638b0b commit 0bfc48f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions datalad/support/gitrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""

from os import linesep
from os.path import join as opj, exists, normpath, isabs, commonprefix, relpath, realpath
from os.path import join as opj, exists, normpath, isabs, commonprefix, relpath, realpath, isdir
from os.path import dirname, basename
import logging
import shlex
Expand Down Expand Up @@ -319,7 +319,7 @@ def git_add(self, files):
else:
lgr.warning("git_add was called with empty file list.")

@normalize_paths
@normalize_paths(match_return_type=False)
def git_remove(self, files, **kwargs):
"""Remove files.
Expand Down
26 changes: 25 additions & 1 deletion datalad/tests/test_gitrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,27 @@ def test_GitRepo_add(src, path):
assert_in(filename, gr.get_indexed_files(), "%s not successfully added to %s" % (filename, path))


@assert_cwd_unchanged
@with_tree(tree={
'd': {'f1': 'content1',
'f2': 'content2'},
'file': 'content3',
'd2': {'f1': 'content1',
'f2': 'content2'},
'file2': 'content3'
})
def test_GitRepo_remove(path):

gr = GitRepo(path, create=True)
gr.git_add('*')
gr.git_commit("committing all the files")

eq_(gr.git_remove('file'), ['file'])
eq_(set(gr.git_remove('d', r=True, f=True)), {'d/f1', 'd/f2'})

eq_(set(gr.git_remove('*', r=True, f=True)), {'file2', 'd2/f1', 'd2/f2'})

@assert_cwd_unchanged
@with_tempfile
def test_GitRepo_commit(path):
Expand Down Expand Up @@ -202,6 +223,8 @@ class testclass(object):
def __init__(self):
self.path = opj('some', 'where')

# TODO
# yoh: logic is alien to me below why to have two since both look identical!
@normalize_paths
def decorated_many(self, files):
return files
Expand All @@ -215,7 +238,8 @@ def decorated_one(self, file_):
# When a single file passed -- single path returned
obscure_filename = get_most_obscure_supported_name()
file_to_test = opj(test_instance.path, 'deep', obscure_filename)
eq_(test_instance.decorated_many(file_to_test),
# file doesn't exist
eq_(test_instance.decorated_one(file_to_test),
_normalize_path(test_instance.path, file_to_test))
eq_(test_instance.decorated_one(file_to_test),
_normalize_path(test_instance.path, file_to_test))
Expand Down

0 comments on commit 0bfc48f

Please sign in to comment.