Skip to content

Status command cannot cope with detached head #116

Description

@bittrance

The status command today depends on libgit2 get_repository_head in order to find the current branch name. However, it does not support detached head (there is a get_repository_head_detached for that but a detached head does not point to a branch so this does not help) and errors with "reference 'HEAD' is neither a local nor a remote branch." Unfortunately, the GitHub checkout action intentionally creates a detached head when checking out for a pull request, meaning that we cannot find the branch name by simply looking at HEAD.

There is a work-around described here actions/checkout#124 (comment) which probably works (doing git checkout ${{ github.head_ref }} between checkout action and gitops-promotion status action seems to resolve the issue. However, I'm thinking the correct fix for this is to require the caller to provide the branch name when calling status. Opinions?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions