openlawlibrary / taf

The Archive Framework
GNU Affero General Public License v3.0
10 stars 10 forks source link

Fix `get_default_branch` method to return a remote default branch #456

Closed n-dusan closed 4 months ago

n-dusan commented 5 months ago

When a repository is initialized locally (not cloned), and has a remote added afterwards, the git symbolic-ref --short refs/remotes/origin/HEAD command fails with an error:

fatal: ref refs/remotes/origin/HEAD is not a symbolic ref

In our current get_default_branch code, we then fall back to running symbolic-ref HEAD --short. However, this is not correct. For example, a local repository can have a completely different branch checked out locally, so the symbolic-ref HEAD --short does not return the default branch.

Related issue.