lab icon indicating copy to clipboard operation
lab copied to clipboard

Open an issue and create a MR out of that issue

Open nvgoldin opened this issue 7 years ago • 11 comments

Hi, I use this GitLab flow a lot:

  1. Create an issue
  2. Click "create merge request" button from the issue, so that GitLab creates the branch and names it according to the issue.

Is it possible to do both these operations with Lab?

nvgoldin avatar May 17 '18 20:05 nvgoldin

@nvgoldin We don't have anything specifically support that workflow right now. I'm not familiar with the functionality in GitLab so I'll have to try it out before I could comment on how to support it here. In the meantime ideas on workflow you'd use within lab would be very welcome. Such as what commands you'd like to execute.

Off the cuff,

lab issue create
.... something here?
lab mr create

zaquestion avatar May 18 '18 01:05 zaquestion

It seems like it is a specific workflow. Is this workflow considerably widespread? If so, what is it called? If not, then seems like you can chain the following generic commands. i.e. if these commands/functionality exists.

You may have to create a merge request and link the MR to the Issue using the edit issue: PUT /projects/:id/issues/:issue_iid https://docs.gitlab.com/ee/api/issues.html#edit-issue

$ lab issue create --show=id
*opens an editor for you to enter the issue details*
535


$ lab create mr --show=id
*opens an editor for you to enter mr details*
989

$ lab issue edit --mr_id=989 535

thoughts?

jspreddy avatar May 18 '18 21:05 jspreddy

Had a chance to try out the "create merge request" on issue feature and it look like it indeed creates a new branch named after the issue and also creates a WIP merge request to be pushed to. With that in mind I'm thinking a couple changes

lab issue create --mr # for creating WIP mr in the same swing as creating an issue
lab issue create mr <issue_id> # for create a WIP mr off an an issue

Part of me worries about the implications of creating empty merge requests that may or may not have changes ready to be pushed... but I'm willing to make these changes. Not sure when I will have the change to get to them however. There are some other requests/issues I'd like to tackle first, and I'm currently swamped at work so I haven't been able to get in any coding here in the last couple weeks.

zaquestion avatar May 22 '18 01:05 zaquestion

@nvgoldin How would the above work for you?

zaquestion avatar Jun 20 '18 03:06 zaquestion

@zaquestion,

lab issue create --mr # for creating WIP mr in the same swing as creating an issue
lab issue create mr <issue_id> # for create a WIP mr off an an issue

The above two would do exactly what I need!

I am surprised this flow is not common actually, I thought that is the 'standard' way of doing things in GitLab. After using it for nearly a year I can't even think of a branch name which does not equal to the issue name.

nvgoldin avatar Jul 03 '18 21:07 nvgoldin

any news here?

nvgoldin avatar Sep 20 '18 19:09 nvgoldin

any news about this issue, thank you

matrixise avatar Sep 22 '21 15:09 matrixise

I think this died on the vine so to speak. Re-reading back through this you want to do

lab issue create --mr # for creating WIP mr in the same swing as creating an issue
lab issue create mr <issue_id> # for create a WIP mr off an an issue

I'll look into it.

prarit avatar Sep 23 '21 13:09 prarit

@matrixise , I took a look at implementing this. I've always created a branch, pushed the branch, and then created an MR on that branch (via lab and the GitLab webUI). I have a public test project [1] where I've created an issue [2] but do not see a "Create a Merge Request" option. Is there something obvious I'm missing?

I do see that GitLab Quick Actions [3] support the creation of an MR from an issue, but only for a previously created branch

ie) /create_merge_request

I have a feeling there is something I'm missing OR perhaps some functionality changed on GitLab.

[1] https://gitlab.com/prarit/Test-Lab [2] https://gitlab.com/prarit/Test-Lab/-/issues/1 [3] https://docs.gitlab.com/ee/user/project/quick_actions.html

prarit avatar Sep 27 '21 11:09 prarit

@bmeneguele @zampierilucas I suppose we could do this one with quick actions as well? What do you two think?

prarit avatar Sep 28 '21 00:09 prarit

@prarit The criteria for the create_merge_request_button and /create_merge_requuest working is[1]:

The Create merge request button doesn’t display if:

  • A branch with the same name already exists.
  • A merge request already exists for this branch.
  • Your project has an active fork relationship.

Which we could use the quick actions to tackle, but I haven't found any API return that confirms if the criteria listed above has met. One other thing that we could do is, create a Mr that contains a message with "Fixes: Issue123" which links the Mr and the issue. That is if we cannot use the gitlab build-in methods.

[1] https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-new-branch-from-an-issue

zampierilucas avatar Sep 28 '21 12:09 zampierilucas