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

repo.active_branch raises TypeError "HEAD is a detached symbolic reference" #1060

Closed
lsaffre opened this issue Sep 24, 2020 · 1 comment
Closed

Comments

@lsaffre
Copy link

@lsaffre lsaffre commented Sep 24, 2020

Accessing the repo.active_branch attribute fails In a repository where I previously checked out some earlier commit. Okay I can try...except to catch this, but IMHO this is unexpected behaviour.

@lsaffre lsaffre changed the title repo.get_status() raises TypeError "HEAD is a detached symbolic reference" repo.active_branch raises TypeError "HEAD is a detached symbolic reference" Sep 24, 2020
@Byron
Copy link
Member

@Byron Byron commented Sep 28, 2020

One can argue that using exception to communicate there is no active branch (as opposed to say, None) is an unfortunate decision - exceptions are always surprising and personally I think they should be avoided if the language permits this.

Returning None where an exception was returned earlier is a breaking change, I believe there is nothing that can be done here. Thus I close the issue as I find nothing constructive, yet.

However, please feel free to propose or implement an alternative way of doing this via comments or a PR. Thank you

@Byron Byron closed this Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.