Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Can't merge a Merge Request if I am in detached HEAD state #735

Closed
jume-dev opened this issue May 20, 2021 · 12 comments · Fixed by #743 or #763
Closed

Can't merge a Merge Request if I am in detached HEAD state #735

jume-dev opened this issue May 20, 2021 · 12 comments · Fixed by #743 or #763
Labels
bug Something isn't working

Comments

@jume-dev
Copy link
Contributor

jume-dev commented May 20, 2021

Description
So, I am running glab in a gitlab-ci pipeline with the goal to create a MR from development to main and automerge it, if the pipeline succeeds.

As I run in an MR pipeline, the git state is a detached HEAD. I try to execute glab mr merge <id> with an correct ID and get the error:
could not determine current branch: git: not on any branch.

Creating the MR with glab mr create -b main -s development -y -t test -d "" did work however

Expected Behavior vs Actual Behavior
It should not give me the error as I am not interacting with the current git state anyway

Possible Fix
Maybe mr merge can be refactored to use whatever mr create is doing.

Your Environment
I am trying to get this pipeline to work:

  stage: release
  image: alpine
  needs: []
  variables:
    DESCRIPTION: test
    SOURCE_BRANCH: $CI_DEFAULT_BRANCH
    TARGET_BRANCH: main
    TITLE: '[Dependency Update] test release'
    TOKEN: $TEST_PAT
  before_script:
    - 'echo "@edge http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories'
    - apk add --no-cache glab@edge
  script:
    - echo $TOKEN | glab auth login --stdin
    - glab mr create -b $TARGET_BRANCH -s $SOURCE_BRANCH -y -t "$TITLE" -d "$DESCRIPTION"
    - export MR_ID=$(glab mr ls -s $SOURCE_BRANCH -t $TARGET_BRANCH | grep ! | awk '{print substr($1,2);}')
    - glab mr merge $MR_ID -R osp-cl/movex/customer-service-2.0/queries/read-config
@jume-dev jume-dev added the bug Something isn't working label May 20, 2021
@profclems
Copy link
Owner

@jume-dev thanks for reporting this issue. I have opened a PR #743 with a fix

@jume-dev
Copy link
Contributor Author

Any timeline when you will do a release with this fix included? :)

@profclems
Copy link
Owner

I have a new release (v1.18.0) planned for tomorrow (1st, June, 2021)...

I'm also working on releasing docker images which you can use directly in your CI #746

@ghost
Copy link

ghost commented Jun 7, 2021

Is there a workaround until 1.18 is released?

(This also affects glab mr update)

@jume-dev
Copy link
Contributor Author

jume-dev commented Jun 8, 2021

You can probably use glab api for it, iirc it supports most of the whole gitlab api

@profclems
Copy link
Owner

Hi @jume-dev @pierlucg-xs, v1.18.0 is available now. It comes with docker images that you can use in your CI environments as well

https://github.com/profclems/glab/releases/v1.18.0

@jume-dev
Copy link
Contributor Author

jume-dev commented Jun 9, 2021

I tried it, but it sadly didn't work. I checked your code change from #743 again and I think I know what the issue is. I provide a PR, but please be aware I have no go experience whatsoever 😁

Would be great if you could release a bugfix release or something :)

EDIT: actually, spoke too soon, I have no idea why your fix doesn't solve the problem

@profclems
Copy link
Owner

profclems commented Jun 9, 2021 via email

@jume-dev
Copy link
Contributor Author

Thanks! I will be glad to review your PR and provide as much help as possible

On 9 Jun 2021, at 8:28 PM, Robert Kranz @.***> wrote:  I tried it, but it sadly didn't work. I checked your code change from #743 again and I think I know what the issue is. I provide a PR, but please be aware I have no go experience whatsoever 😁 Would be great if you could release a bugfix release or something :) — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

Hi, sorry, as you answered via mail, you probably didn't saw my edit. I checked the code more thoroughly and I can't seem to find what's the problem. Looks ok for me

@jume-dev
Copy link
Contributor Author

Scratch that, I got me some help from a colleague and we think we found the issue. I opened up an PR, please be so kind to review.

I'd love it if you could make a small bugfix release for this fix, as I really depend on it for my project, but if not, that would be also ok, as I can use my fork.

@profclems
Copy link
Owner

Hi @jume-dev… I have merged your PR and did a patch release… Thanks a lot for working on this!

https://github.com/profclems/glab/releases/v1.18.1

@jume-dev
Copy link
Contributor Author

you're welcome :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
2 participants