Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add raw_branch_name to pygit2.Branch #954

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add raw_branch_name to pygit2.Branch
  • Loading branch information
istephens committed Nov 14, 2019
commit a033bb32ad5b19032457b8f795ea10fe92f95d8e
18 changes: 18 additions & 0 deletions src/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,23 @@ Branch_branch_name__get__(Branch *self)
return Error_set(err);
}

PyDoc_STRVAR(Branch_raw_branch_name__doc__,
"The name of the local or remote branch (bytes).");

PyObject *
Branch_raw_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 PyBytes_FromString(c_name);
else
return Error_set(err);
}

PyDoc_STRVAR(Branch_remote_name__doc__,
"The name of the remote set to be the upstream of this branch.");
Expand Down Expand Up @@ -263,6 +280,7 @@ PyMethodDef Branch_methods[] = {

PyGetSetDef Branch_getseters[] = {
GETTER(Branch, branch_name),
GETTER(Branch, raw_branch_name),
GETTER(Branch, remote_name),
GETSET(Branch, upstream),
GETTER(Branch, upstream_name),
Expand Down
2 changes: 2 additions & 0 deletions test/test_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ def test_branch_name(self):
branch = self.repo.branches.get('master')
assert branch.branch_name == 'master'
assert branch.name == 'refs/heads/master'
assert branch.raw_branch_name == branch.branch_name.encode('utf-8')

branch = self.repo.branches.get('i18n')
assert branch.branch_name == 'i18n'
assert branch.name == 'refs/heads/i18n'
assert branch.raw_branch_name == branch.branch_name.encode('utf-8')

def test_with_commit(self):
branches = self.repo.branches.with_commit(EXCLUSIVE_MASTER_COMMIT)
Expand Down