matteosister / GitElephant

An abstraction layer for git written in PHP
GNU Lesser General Public License v3.0
613 stars 74 forks source link

getBranches() fails when the repository is in a detached state #125

Closed TiEul closed 6 years ago

TiEul commented 7 years ago

Hey,

when a repository has been put into a detached state getBranches() will throw an InvalidArgumentException in \GitElephant\Objects\Branch::getMatches because it will try to handle strings of the following pattern:

* (HEAD detached at 12345abc) 12345abcdefg123456789abcdefghijklmnopqrstuv SOME_GIT_COMMIT_MESSAGE

There is a workaround by checking out an existing branch before, however, since I cannot be sure that all repositories have a master branch, for example, there is no clean way to currently get around this issue. GitElephant should be able to handle detached states and ignore them in the branch listing.

MLukman commented 6 years ago

Same with the issue #99 that I previously raised