Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open the current merge request with lab mr -b #218

Closed
MartinDelille opened this issue Sep 18, 2018 · 12 comments
Closed

Open the current merge request with lab mr -b #218

MartinDelille opened this issue Sep 18, 2018 · 12 comments

Comments

@MartinDelille
Copy link
Contributor

When I'm working on a branch, I'd like to open the current merge request.

Currently I need to list the merge request like this:

$ lab mr list
#90 WIP: Resolve "memory leak"
#104 WIP: Resolve "Export to adobe"
#14 WIP: Resolve "Port to iOS"

Then browse the one I'm working on:

$ lab mr b 90

This would be nice to be able to directly open the merge request from the current branch like this:

$ lab mr b
@zaquestion
Copy link
Owner

Completely agree and it's definitely on the roadmap. The next big thing is an MR review workflow for the cli. The ability to do the above among other contextual mr tasks is first up.

@zaquestion
Copy link
Owner

Would definitely accept an mr ;)

@MartinDelille
Copy link
Contributor Author

Currently the comand lab mr b open https://gitlab.delille.org/mygroup/myproject/merge_requests.

Should we keep this behavior?

I would propose to change my command to lab mr o (o for open).

Any idea how to query the go mr from the current branch?

I'm learning Go so I'll be happy to contribute but I might need a little help!

@zaquestion
Copy link
Owner

It seems like we should always open the current mr, unless we can't determine it (like if there isn't an me yet).

There should be a way to do it with the API, if you tried to open an mr that already exists for a branch it will complain for example, so I imagine the logic is there to look up my by branch

@zaquestion
Copy link
Owner

Looks like the API supports this https://docs.gitlab.com/ee/api/merge_requests.html#list-project-merge-requests

I'd suggest listing all the MR with source_branch=<current branch>. We'll need rules on how to pick the correct MR. Something like use the MR where the target is master, else use the first MR in the list.

@zaquestion
Copy link
Owner

Looks like we've already got a function for listing the MRs here:
https://github.com/zaquestion/lab/blob/master/internal/gitlab/gitlab.go#L187

Probably we'll want to write a new function which calls MRList and used the logic in the previous post and somehow wire that into the beginning of cmd/mr_browse.go so that if we find an MR and no arguments were provided we use that.

@MartinDelille
Copy link
Contributor Author

Ok I have an issue getting lab:

$ go get github.com/zaquestion/lab
...
../go/src/github.com/zaquestion/lab/cmd/ci_view.go:323:61: undefined: tview.ANSIIWriter

The error is located here.

@zaquestion
Copy link
Owner

I still need to upgrade to modules so right now dependencies are managed with deep

go get -u -d github.com/zaquestion/lab
cd $GOPATH/src/github.com/zaquestion/lab
dep ensure

@zaquestion
Copy link
Owner

@MartinDelille
Copy link
Contributor Author

When I try go run go run main.go mr b, it tries to open https://mygitlabinstance.com/zaquestion/lab/merge_requests

@zaquestion
Copy link
Owner

That's lab looking at the current directory to get the project name, but using the configured hostname. Usually I use a command like go install $GOPATH/github.com/zaquestion/lab && lab mr browse in a test directory

@MartinDelille
Copy link
Contributor Author

I use two gitlab instance. My own and gitlab.com. Maybe we should read the hostname from the remote? Anyway this would be another issue.

MartinDelille added a commit to MartinDelille/lab that referenced this issue Sep 23, 2018
@zaquestion zaquestion added this to the 0.14.0 milestone Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants