Index: add a setter for workdir
This commit is contained in:
@@ -512,6 +512,27 @@ Repository_workdir__get__(Repository *self, void *closure)
|
|||||||
return to_path(c_path);
|
return to_path(c_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Repository_workdir__set__(Repository *self, PyObject *py_workdir)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
const char *workdir;
|
||||||
|
PyObject *tworkdir;
|
||||||
|
|
||||||
|
workdir = py_str_borrow_c_str(&tworkdir, py_workdir, NULL);
|
||||||
|
if (workdir == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
err = git_repository_set_workdir(self->repo, workdir, 0 /* update_gitlink */);
|
||||||
|
Py_DECREF(tworkdir);
|
||||||
|
if (err < 0) {
|
||||||
|
Error_set_str(err, workdir);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(Repository_merge_base__doc__,
|
PyDoc_STRVAR(Repository_merge_base__doc__,
|
||||||
"merge_base(oid, oid) -> Oid\n"
|
"merge_base(oid, oid) -> Oid\n"
|
||||||
"\n"
|
"\n"
|
||||||
@@ -1597,7 +1618,7 @@ PyGetSetDef Repository_getseters[] = {
|
|||||||
GETTER(Repository, head_is_unborn),
|
GETTER(Repository, head_is_unborn),
|
||||||
GETTER(Repository, is_empty),
|
GETTER(Repository, is_empty),
|
||||||
GETTER(Repository, is_bare),
|
GETTER(Repository, is_bare),
|
||||||
GETTER(Repository, workdir),
|
GETSET(Repository, workdir),
|
||||||
GETTER(Repository, default_signature),
|
GETTER(Repository, default_signature),
|
||||||
GETTER(Repository, _pointer),
|
GETTER(Repository, _pointer),
|
||||||
{NULL}
|
{NULL}
|
||||||
|
@@ -190,6 +190,11 @@ class RepositoryTest_II(utils.RepoTestCase):
|
|||||||
expected = realpath(self.repo_path)
|
expected = realpath(self.repo_path)
|
||||||
self.assertEqual(directory, expected)
|
self.assertEqual(directory, expected)
|
||||||
|
|
||||||
|
def test_set_workdir(self):
|
||||||
|
directory = tempfile.mkdtemp()
|
||||||
|
self.repo.workdir = directory
|
||||||
|
self.assertEqual(realpath(self.repo.workdir), realpath(directory))
|
||||||
|
|
||||||
def test_checkout_ref(self):
|
def test_checkout_ref(self):
|
||||||
ref_i18n = self.repo.lookup_reference('refs/heads/i18n')
|
ref_i18n = self.repo.lookup_reference('refs/heads/i18n')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user