firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.03k stars 115 forks source link

Failed to determine default branch using `refs/remotes/origin/HEAD` #1267

Closed fschrempf closed 2 weeks ago

fschrempf commented 2 weeks ago

gitlab-ci-local uses git symbolic-ref --short refs/remotes/origin/HEAD to determine the remote default branch in GitLab. Depending on how the local repository was setup, this might not be available (see this link for details) and causing failures like this:

Error: Command failed with exit code 128: git symbolic-ref --short refs/remotes/origin/HEAD

A workaround is to add the symbolic-ref manually as described here.

A fix might be possible by parsing the output from git remote show origin to determine the default branch as described here.

Expected behavior

gitlab-ci-local runs without failure even if refs/remotes/origin/HEAD is not available

Host information Manjaro gitlab-ci-local 4.50.1

Containerd binary podman version 5.1.0

ANGkeith commented 2 weeks ago

Expected behavior gitlab-ci-local runs without failure even if refs/remotes/origin/HEAD is not available

most likely the issue whereas gitlab-ci-local crashes will be resolved by https://github.com/firecow/gitlab-ci-local/pull/1256/files

is this the error you're getting? image

if yes, then on the next release, this issue will most likely be fixed

ANGkeith commented 2 weeks ago

A fix might be possible by parsing the output from git remote show origin to determine the default branch as described https://github.com/jhauberg/gitdoctor/issues/3#issuecomment-467979523.

yup, i think git remote show origin will be a nice to have, but it's a very expensive operation. took ~ 4 seconds on my computer.

i don't think i'll be implementing it though, but if someone is, just take note of this, and maybe cache the result or something

fschrempf commented 2 weeks ago

Confirming that 4.51.0 seems to fix the issue. Thanks! Great work!