scm: require abs path

Fixes #1136

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-09-20 00:14:16 +03:00
parent 04efd1d6d3
commit e1841f07cb
2 changed files with 6 additions and 6 deletions
+2 -3
View File
@@ -109,10 +109,9 @@ class Git(Base):
return self.GITIGNORE
def _get_gitignore(self, path):
assert os.path.isabs(path)
entry = os.path.basename(path)
gitignore = os.path.join(os.path.abspath(os.path.dirname(path)),
self.GITIGNORE)
gitignore = os.path.abspath(os.path.realpath(gitignore))
gitignore = os.path.join(os.path.dirname(path), self.GITIGNORE)
if not gitignore.startswith(self.root_dir):
raise FileNotInRepoError(path)
+4 -3
View File
@@ -35,13 +35,14 @@ class TestIgnore(TestGit):
def test(self):
git = Git(self._root_dir)
foo = os.path.join(self._root_dir, self.FOO)
git.ignore('foo')
git.ignore(foo)
self.assertTrue(os.path.isfile(Git.GITIGNORE))
self.assertEqual(self._count_gitignore(), 1)
git.ignore('foo')
git.ignore(foo)
self.assertEqual(self._count_gitignore(), 1)
git.ignore_remove('foo')
git.ignore_remove(foo)
self.assertEqual(self._count_gitignore(), 0)