lab icon indicating copy to clipboard operation
lab copied to clipboard

lab issue create mr

Open dooraim opened this issue 3 years ago • 4 comments

Hi, I saw that when you create an Issue it is not possible to create an MR, which instead you can do through Gitlab's web interface, as shown in the image below. Is this features still not yet available or will it not be implemented?

immagine

dooraim avatar Nov 02 '22 11:11 dooraim

Sorry for the very late reply. I am going through some old issues and seeing what can be done to resolve them.

@zampierilucas , I don't see anything obvious with the Merge Request or Issue APIs that allows this sort of linking, even though there are references to being able to do so. Any idea on where I might find the API magic?

prarit avatar Jul 13 '23 23:07 prarit

@prarit The feature @dooraim is looking for is creating_merge_requests.html#from-an-issue, and from those docs "selecting Create merge request redirects to the merge request creation form instead of immediately creating the merge request.", so there's no API to directly do that.

But what GitLab does in the backend is quite simple, it does two things:

  • Adds "Closes $ISSUE_ID" to the mr description, that's creates a reference between the mr to an issue, so when the mr is merged, the issue is also resolved.
  • Created a branch and pushed it based on the issue title, example this issue is named "Consider building this in COPR": image

So the resulting mr is an empty(no commits) mr like: image

This can probably be scripted using pipes in lab, but we can also implement it, wdyt?

zampierilucas avatar Jul 14 '23 13:07 zampierilucas

Interesting thought. But I wonder if it is easier just to append the Description with a 'Closes' line?

prarit avatar Jul 14 '23 13:07 prarit

Sure, GitLab will see as the same as using the button on the issue, we would only be missing the convenience of having a branch name and description based on the issue data, unless manually created.

zampierilucas avatar Jul 14 '23 13:07 zampierilucas