After the push is complete, git issues a URL to create a merge request. It looks like this:

/merge_requests/new?merge_request[source_branch]=BRANCH_NAME 

At this URL opens the form in which you need to fill in all fields. Adding &merge_request[assignee_id]=ID to this URL (see Gitlab API ) allows you to automatically set the desired value in the "Assign to". But if you add &merge_request[title]=TITLE , then your title is not picked up. Is there any way to solve this problem?

PS In principle, you can immediately make POST directly into the guts of the gitlab, as described in the same API. But the stage of the form can not be skipped, it is needed. I just want to substitute my title, by analogy с assignee_id .

  • I read the source, found only the title of the same name tick, which closes the branch, if the branch format номер_тикета-описание . Most likely, you should write a feature request. Or create through API and propose correct post-factum. - D-side
  • No, the second option does not fit. Made a crutch through Tampermonkey for now ... - PinkTux
  • I didn’t even consider the options “to make on the client individually”, but if it works for you, why not :) - D-side
  • So assignee_id is still on the client in the URL is substituted, however, easier - sed'om on the conclusion of git push ... :) But, of course, I would like to solve the problem at a different level. - PinkTux

1 answer 1

Solution on the client side. It was written for Tampermonkey / Chromium, but it seems to fit all other browsers. When the Merge Request form is opened, it fills in the "description", "who accepts" and "header" fields, if specified.

 // ==UserScript== // @name Gitlab Merge Request additions // @namespace http://tampermonkey.net/ // @version 0.5 // @description Add title, labels, description & assignee_id to merge request // @match https://gitlab.*/merge_requests/new* // @run-at document-start // @grant none // ==/UserScript== (function() { 'use strict'; /* replace by own: */ var ASSIGNEE_ID = "666"; //var LABELS = "фича"; var DESCRIPTION = "Вставь описание, дундук!"; /* based on http://stackoverflow.com/questions/8486099/ code */ function parse_query_string() { var query = location.search.substr(1); var result = {}; query.split("&").forEach(function(part) { if(!part) return; part = decodeURIComponent(part.split("+").join(" ")); var eq = part.indexOf("="); var key = eq>-1 ? part.substr(0,eq) : part; var val = eq>-1 ? part.substr(eq+1) : ""; var from = key.indexOf("["); if(from==-1) result[decodeURIComponent(key)] = val; else { var to = key.indexOf("]"); var index = decodeURIComponent(key.substring(from+1,to)); key = decodeURIComponent(key.substring(0,from)); if(!result[key]) result[key] = []; if(!index) result[key].push(val); else result[key][index] = val; } }); return result; } var q = parse_query_string(); if( !q.merge_request || !q.merge_request.source_branch ) return; /* * Как правильно внедриться в DOM тут не придумал, поэтому * делаем редирект при необходимости добавить assignee_id * (потому и @run-at document-start) */ if( typeof ASSIGNEE_ID != "undefined" && parseInt(ASSIGNEE_ID) && !q.merge_request.assignee_id ) { var loc = Object.keys(q.merge_request).map( function(key) { return "merge_request[" + key + "]=" + q.merge_request[key]; }).join("&") + "&merge_request[assignee_id]=" + ASSIGNEE_ID; document.location.search = loc; return; } document.addEventListener("DOMContentLoaded", function() { var e = document.getElementById("merge_request_title"); if( e ) { /* title = BRANCH_NAME - 'empty placeholder' */ e.value = q.merge_request.source_branch + " - ''"; } if( typeof LABELS != "undefined" ) { /* id может быть и другим! */ e = document.getElementById("s2id_autogen3"); if( e ) e.value = LABELS; } if( typeof DESCRIPTION != "undefined" ) { e = document.getElementById("merge_request_description"); if( e ) e.value = DESCRIPTION; } }); })();