Rename Merge Request Title Automatically

Compatible gitlab

  1. // ==UserScript==
  2. // @name Rename Merge Request Title Automatically
  3. // @name:es Rename Merge Request Title Automatically
  4. // @description Compatible gitlab
  5. // @description:es Compatible gitlab
  6. // @date 2022-03-21
  7. // @compatible chrome
  8. // @compatible firefox
  9. // @compatible opera
  10. // @compatible safari
  11. // @license CC BY-NC-ND 4.0 International. https://creativecommons.org/licenses/by-nc-nd/4.0/
  12. // @match *://*.gitlab.com/*
  13. // @match *://gitlab.*.com.*/*
  14. // @version 0.1
  15. // @namespace https://gf.qytechs.cn/en/users/314553-stefango
  16. // ==/UserScript==
  17. (() => {
  18. if (window.location.href.includes('cherry-pick')) {
  19. const branchSelector = document.getElementsByClassName("branch-selector");
  20. const texto = branchSelector[0].innerText;
  21. const textoToInput = texto.split(' ');
  22. const source = textoToInput[1];
  23. const target = textoToInput[3];
  24. const url = window.location.href;
  25. const originalTitle = document.getElementById("merge_request_title").value;
  26.  
  27. if (originalTitle.startsWith('Merge branch')) {
  28. let titleArr = document.getElementById("merge_request_title").value.split(' ');
  29. titleArr.splice(-1, 1, `'${target}'`);
  30. document.getElementById("merge_request_title").value = titleArr.join(' ');
  31. } else {
  32. // rename manually when code conflicted
  33. }
  34. }
  35. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址