GitPython
GitPython copied to clipboard
repositories that are not in a detached state are recognized as detached
user@host:~/src$ git clone https://github.com/gitpython-developers/GitPython.git
Cloning into 'GitPython'...
remote: Enumerating objects: 14646, done.
remote: Total 14646 (delta 0), reused 0 (delta 0), pack-reused 14646
Receiving objects: 100% (14646/14646), 7.65 MiB | 4.21 MiB/s, done.
Resolving deltas: 100% (9125/9125), done.
user@host:~/src$ cd GitPython/
user@host:~/src/GitPython$ ipython3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
Type "copyright", "credits" or "license" for more information.
In [1]: import git
In [2]: repo = git.Repo()
In [3]: repo.active_branch
Out[3]: <git.Head "refs/heads/master">
In [4]: repo.active_branch.is_detached
Out[4]: True
Do I miss something here? I do not think that this freshly cloned repository is in a detached state.
Thanks for pointing this out! I was able to reproduce it, too, and do wonder how that could break knowing there is quite some test coverage.
What fixed this issue for me, was setting the following on a Jenkins job config (in the checkout section):
Check out to matching local branch
Tried another build and it completed successfully after a day of scratching my head. The detached error wasn't appearing locally, so that's what made me suspect the Jenkins checkout settings.
I'd also re-created the repo and only had one commit, so the detached error didn't seem to make any sense.