mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
gitignore: use unambiguous paths
Fixes #1324 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+2
-1
@@ -151,7 +151,8 @@ class Git(Base):
|
||||
|
||||
def _get_gitignore(self, path):
|
||||
assert os.path.isabs(path)
|
||||
entry = os.path.basename(path)
|
||||
# NOTE: using '/' prefix to make path unambiguous
|
||||
entry = '/' + os.path.basename(path)
|
||||
gitignore = os.path.join(os.path.dirname(path), self.GITIGNORE)
|
||||
|
||||
if not gitignore.startswith(self.root_dir):
|
||||
|
||||
@@ -205,8 +205,8 @@ class TestGitIgnoreBasic(CheckoutBase):
|
||||
|
||||
self.assertEqual(len(ignored), 2)
|
||||
|
||||
self.assertIn(fname1, ignored)
|
||||
self.assertIn(fname2, ignored)
|
||||
self.assertIn('/' + fname1, ignored)
|
||||
self.assertIn('/' + fname2, ignored)
|
||||
|
||||
|
||||
class TestGitIgnoreWhenCheckout(CheckoutBase):
|
||||
@@ -232,13 +232,13 @@ class TestGitIgnoreWhenCheckout(CheckoutBase):
|
||||
ignored = self.read_ignored()
|
||||
|
||||
self.assertEqual(len(ignored), 1)
|
||||
self.assertIn(fname_master, ignored)
|
||||
self.assertIn('/' + fname_master, ignored)
|
||||
|
||||
self.dvc.scm.checkout(branch_1)
|
||||
ret = main(['checkout'])
|
||||
self.assertEqual(ret, 0)
|
||||
ignored = self.read_ignored()
|
||||
self.assertIn(fname_branch, ignored)
|
||||
self.assertIn('/' + fname_branch, ignored)
|
||||
|
||||
|
||||
class TestCheckoutMissingMd5InStageFile(TestRepro):
|
||||
|
||||
+2
-1
@@ -45,7 +45,8 @@ class TestIgnore(TestGit):
|
||||
def _count_gitignore(self):
|
||||
with open(Git.GITIGNORE, 'r') as fd:
|
||||
lines = fd.readlines()
|
||||
return len(list(filter(lambda x: x.strip() == 'foo', lines)))
|
||||
return len(list(filter(lambda x: x.strip() == '/' + self.FOO,
|
||||
lines)))
|
||||
|
||||
def test(self):
|
||||
git = Git(self._root_dir)
|
||||
|
||||
Reference in New Issue
Block a user