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

ValueError repo.branches.get('branch_no_exist/') trailing slashes in branch names #832

Open
Richard-Mathie opened this issue Oct 25, 2018 · 2 comments
Labels

Comments

@Richard-Mathie
Copy link

if i have a repo and call

>> 'branch_no_exist' in repo.branches
False

as expected, but

>> 'branch_no_exist/' in repo.branches
Traceback (most recent call last):

  pygit2/repository.py", line 1156, in get
    return self[key]
 pygit2/repository.py", line 1144, in __getitem__
    branch = self._repository.lookup_branch(name, GIT_BRANCH_LOCAL)
ValueError: cannot locate local branch 'branch_no_exist/'

Given branch names Shouldn't end in a slash, but the error is not complaining about this.

should repository.lookup_branch be returning None in this case?

@jdavid
Copy link
Member

jdavid commented Oct 25, 2018

This looks related to issue #828

If branch names are not allowed to have slashes then it should fail with an informative error, probably InvalidSpecError since PR #829 ; did you test with latest version of the master branch?

Definitive name of the exception may change before the next release, see issue #830

@yoichi
Copy link

yoichi commented Oct 23, 2021

To get the expected result (without throwing exception), create list as:

>>> 'branch_no_exist/' in list(repo.branches)
False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants