Implement Branch.branch_name.
This commit is contained in:
19
src/branch.c
19
src/branch.c
@@ -105,6 +105,24 @@ PyObject* Branch_rename(Branch *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PyDoc_STRVAR(Branch_branch_name__doc__,
|
||||||
|
"The name of the local or remote branch.");
|
||||||
|
|
||||||
|
PyObject* Branch_branch_name__get__(Branch *self)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
const char *c_name;
|
||||||
|
|
||||||
|
CHECK_REFERENCE(self);
|
||||||
|
|
||||||
|
err = git_branch_name(&c_name, self->reference);
|
||||||
|
if (err == GIT_OK)
|
||||||
|
return to_unicode(c_name, NULL, NULL);
|
||||||
|
else
|
||||||
|
return Error_set(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PyMethodDef Branch_methods[] = {
|
PyMethodDef Branch_methods[] = {
|
||||||
METHOD(Branch, delete, METH_NOARGS),
|
METHOD(Branch, delete, METH_NOARGS),
|
||||||
METHOD(Branch, is_head, METH_NOARGS),
|
METHOD(Branch, is_head, METH_NOARGS),
|
||||||
@@ -113,6 +131,7 @@ PyMethodDef Branch_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
PyGetSetDef Branch_getseters[] = {
|
PyGetSetDef Branch_getseters[] = {
|
||||||
|
GETTER(Branch, branch_name),
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -110,6 +110,15 @@ class BranchesTestCase(utils.RepoTestCase):
|
|||||||
self.assertRaises(ValueError,
|
self.assertRaises(ValueError,
|
||||||
lambda: original_branch.rename('abc@{123'))
|
lambda: original_branch.rename('abc@{123'))
|
||||||
|
|
||||||
|
def test_branch_name(self):
|
||||||
|
branch = self.repo.lookup_branch('master')
|
||||||
|
self.assertEqual(branch.branch_name, 'master')
|
||||||
|
self.assertEqual(branch.name, 'refs/heads/master')
|
||||||
|
|
||||||
|
branch = self.repo.lookup_branch('i18n')
|
||||||
|
self.assertEqual(branch.branch_name, 'i18n')
|
||||||
|
self.assertEqual(branch.name, 'refs/heads/i18n')
|
||||||
|
|
||||||
|
|
||||||
class BranchesEmptyRepoTestCase(utils.EmptyRepoTestCase):
|
class BranchesEmptyRepoTestCase(utils.EmptyRepoTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Reference in New Issue
Block a user