Improve discoverability when pushing code to GitLab
Problem to solve
When pushing code to a GitLab repository, in special ocasions we provide a URL that either allow user to follow up on the web UI (like when pushing code to a branch that has a MR open), or allow them to trigger an action that can only be done on the Web UI (when pushing a new branch to the repository, a URL is sent that allows the user to create a Merge Request).
There are other situations where may be useful for the user to have a quick URL bringing them back to the Web UI. We should explore few alternatives here.
Further details
-
@sytses said here: https://gitlab.com/gitlab-org/gitlab-ce/issues/53012#note_111182448
when I push a commit to the default brach I would love to get a url back that shows the commit like gitlab-com/www-gitlab-com@c7ec37c7 so I can share that with co-workers.
-
@stanhu said here: https://gitlab.com/gitlab-org/gitlab-ce/issues/53012#note_111183107
I often want to change the target branch (e.g. for security releases), so it would be nice if there were a way to also supply this in a friendly way. Right now I append something like
merge_request[target_branch]=my-target-branchto the URL.
Proposal
When pushing to the default branch (usually master), instead of displaying something like this:
remote:
remote: View merge request for 1234-awesome-branch:
remote: https://gitlab.com/gitlab-com/www-gitlab-com/merge_requests/1234
remote:
Display something like this:
remote:
remote: You've pushed directly to 'master'. You can view your last commit in GitLab:
remote: https://gitlab.com/gitlab-com/www-gitlab-com/commit/c7ec37c7e8db83009a6c3b754a0c108828326730
remote:
To do that we need to edit the internal API, make it send the last commit URL when pushing to the main branch.
We currently have this internal endpoint: /internal/merge_request_urls we probably want to rename this to something that describes returning both a merge request or a commit url (like: /internal/gitlab_reference_url. We may also want to change returned params to indicate when it's a merge request or when it's a commit URL we are sending, so gitlab-shell and gitlab-workhorse can build the message accordingly.
For the second item, app/controllers/projects/merge_requests/creations_controller.rb should accept simple query url param: target_branch when building the merge request object which will build the new merge request screen.
What does success look like, and how can we measure that?
- Being able to set a target branch by using a URL pattern like:
https://#{gitlab.host}/:namespace/:project_path/merge_requests/new/:source_branch_name?target_branch=:target_branch_name
- When pushing to the default branch, receive a message like in the example below:
remote:
remote: You've pushed directly to 'master'. You can view your last commit in GitLab:
remote: https://gitlab.com/gitlab-com/www-gitlab-com/commit/c7ec37c7e8db83009a6c3b754a0c108828326730
remote: