* Implement MemoryRepo.{set_description,get_description}.
(Jelmer Vernooij)
+ * Raise exception in Repo.stage() when absolute paths are
+ passed in. Allow passing in relative paths to
+ porcelain.add().(Jelmer Vernooij)
+
0.16.3 2016-01-14
TEST FIXES
:param repo: Repository for the files
:param paths: Paths to add. No value passed stages all modified files.
"""
- # FIXME: Support patterns, directories.
with open_repo_closing(repo) as r:
if not paths:
# If nothing is specified, add all non-ignored files.
dirnames.remove('.git')
for filename in filenames:
paths.append(os.path.join(dirpath[len(r.path)+1:], filename))
- r.stage(paths)
+ # TODO(jelmer): Possibly allow passing in absolute paths?
+ relpaths = []
+ if not isinstance(paths, list):
+ paths = [paths]
+ for p in paths:
+ # FIXME: Support patterns, directories.
+ if os.path.isabs(p) and p.startswith(repo.path):
+ relpath = os.path.relpath(p, repo.path)
+ else:
+ relpath = p
+ relpaths.append(relpath)
+ r.stage(relpaths)
def rm(repo=".", paths=None):
for fs_path in fs_paths:
if not isinstance(fs_path, bytes):
fs_path = fs_path.encode(sys.getfilesystemencoding())
+ if os.path.isabs(fs_path):
+ raise ValueError(
+ "path %r should be relative to "
+ "repository root, not absolute" % fs_path)
tree_path = _fs_to_tree_path(fs_path)
full_path = os.path.join(root_path_bytes, fs_path)
try:
def init_bare(cls, path):
"""Create a new bare repository.
- ``path`` should already exist and be an emty directory.
+ ``path`` should already exist and be an empty directory.
:param path: Path to create bare repository in
:return: a `Repo` instance
with open(os.path.join(self.repo.path, 'foo'), 'w') as f:
f.write("BAR")
porcelain.add(self.repo.path, paths=["foo"])
+ self.assertIn("foo", self.repo.open_index())
+
+ def test_add_file_absolute_path(self):
+ # Absolute paths are (not yet) supported
+ with open(os.path.join(self.repo.path, 'foo'), 'w') as f:
+ f.write("BAR")
+ porcelain.add(self.repo, paths=[os.path.join(self.repo.path, "foo")])
+ self.assertIn("foo", self.repo.open_index())
class RemoveTests(PorcelainTestCase):
self.assertEqual([self._root_commit], r[commit_sha].parents)
self.assertEqual(old_refs, r.get_refs())
+ def test_stage_absolute(self):
+ r = self._repo
+ os.remove(os.path.join(r.path, 'a'))
+ self.assertRaises(ValueError, r.stage, [os.path.join(r.path, 'a')])
+
def test_stage_deleted(self):
r = self._repo
os.remove(os.path.join(r.path, 'a'))