Skip to content
Snippets Groups Projects
Commit 1892b903 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

feat(gitlab): use markdown for pr bodies

parent 6f868c83
No related branches found
No related tags found
No related merge requests found
const is = require('@sindresorhus/is'); const is = require('@sindresorhus/is');
const addrs = require('email-addresses'); const addrs = require('email-addresses');
const showdown = require('showdown');
const get = require('./gl-got-wrapper'); const get = require('./gl-got-wrapper');
const endpoints = require('../../util/endpoints'); const endpoints = require('../../util/endpoints');
const converter = new showdown.Converter();
converter.setFlavor('github');
let config = {}; let config = {};
module.exports = { module.exports = {
...@@ -704,15 +700,7 @@ async function mergePr(iid) { ...@@ -704,15 +700,7 @@ async function mergePr(iid) {
function getPrBody(input) { function getPrBody(input) {
// Convert to HTML using GitHub-flavoured markdown as it is more feature-rich than GitLab's flavour // Convert to HTML using GitHub-flavoured markdown as it is more feature-rich than GitLab's flavour
return converter return input.replace(/Pull Request/g, 'Merge Request').replace(/PR/g, 'MR');
.makeHtml(input)
.replace(/<\/?h4[^>]*>/g, '**') // See #954
.replace(/Pull Request/g, 'Merge Request')
.replace(/PR/g, 'MR')
.replace(/<summary>/g, '<h1>')
.replace(/<\/summary><\/p>/g, '</h1>')
.replace(/<p><details><br \/>\n/g, '')
.replace(/<p><\/details><\/p>\n/g, '');
// TODO: set maximum length // TODO: set maximum length
} }
......
...@@ -243,7 +243,7 @@ Object { ...@@ -243,7 +243,7 @@ Object {
} }
`; `;
exports[`platform/gitlab getPrBody(input) returns updated pr body 1`] = `"<p><a href=\\"https://github.com/foo/bar/issues/5\\">https://github.com/foo/bar/issues/5</a> plus also <a href=\\"https://github.com/foo/bar/issues/5\\">a link</a></p>"`; exports[`platform/gitlab getPrBody(input) returns updated pr body 1`] = `"https://github.com/foo/bar/issues/5 plus also [a link](https://github.com/foo/bar/issues/5)"`;
exports[`platform/gitlab getPrFiles() returns files 1`] = ` exports[`platform/gitlab getPrFiles() returns files 1`] = `
Array [ Array [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment