Compare commits
2 Commits
dev
...
4975-Send-
Author | SHA1 | Date |
---|---|---|
Guillermo Bonet | db282cf74b | |
Guillermo Bonet | a59807e7fc |
|
@ -26,6 +26,11 @@ module.exports = Self => {
|
|||
type: 'string',
|
||||
required: true,
|
||||
description: `The old version number`
|
||||
}, {
|
||||
arg: 'description',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: `The description of changes`
|
||||
}, {
|
||||
arg: 'unlock',
|
||||
type: 'boolean',
|
||||
|
@ -42,8 +47,7 @@ module.exports = Self => {
|
|||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.upload = async(ctx, appName, toVersion, branch, fromVersion, unlock, options) => {
|
||||
Self.upload = async(ctx, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
const $t = ctx.req.__; // $translate
|
||||
|
@ -51,6 +55,12 @@ module.exports = Self => {
|
|||
const AccessContainer = models.AccessContainer;
|
||||
const fileOptions = {};
|
||||
let tx;
|
||||
const appName = ctx.args.appName;
|
||||
const toVersion = ctx.args.toVersion;
|
||||
const branch = ctx.args.branch;
|
||||
const fromVersion = ctx.args.fromVersion;
|
||||
let description = ctx.args.description;
|
||||
const unlock = ctx.args.unlock;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
@ -133,12 +143,48 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
|
||||
let formatDesc;
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
if (branch == 'master' || 'test' || 'dev')
|
||||
formatDesc = `> :branch_${branch}: `;
|
||||
else
|
||||
formatDesc = `> :branch: `;
|
||||
|
||||
formatDesc += `*${appName.toUpperCase()}* v.${toVersion} `;
|
||||
const fromBranch = await models.MdbVersionTree.find({
|
||||
where: {version: fromVersion},
|
||||
fields: ['branchFk']
|
||||
});
|
||||
if (branch == fromBranch[0].branchFk)
|
||||
formatDesc += `[*${branch}*]: `;
|
||||
else
|
||||
formatDesc += `[*${fromBranch}* » *${branch}*]: `;
|
||||
|
||||
const params = await models.MdbConfig.find({});
|
||||
const issueTrackerUrl = params[0].issueTrackerUrl;
|
||||
const issueNumberRegex = params[0].issueNumberRegex;
|
||||
const chatDestination = params[0].chatDestination;
|
||||
|
||||
const regex = new RegExp(issueNumberRegex, 'g');
|
||||
const matches = description.matchAll(regex);
|
||||
if (matches) {
|
||||
for (const match of matches) {
|
||||
let issueId = match[0];
|
||||
let newUrl = issueTrackerUrl.replace('{index}', match[1]);
|
||||
description = description.replace(` ${issueId}`, ` [${issueId}](${newUrl})`);
|
||||
}
|
||||
}
|
||||
formatDesc += description;
|
||||
|
||||
await models.Chat.send(ctx, chatDestination, formatDesc, myOptions);
|
||||
|
||||
await models.MdbVersionTree.create({
|
||||
app: appName,
|
||||
version: toVersion,
|
||||
branchFk: branch,
|
||||
fromVersion,
|
||||
userFk: userId
|
||||
userFk: userId,
|
||||
description
|
||||
}, myOptions);
|
||||
|
||||
await models.MdbVersion.upsert({
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
"MdbVersionTree": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"MdbConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"AccessContainer": {
|
||||
"dataSource": "accessStorage"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "MdbConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "mdbConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"id": true
|
||||
},
|
||||
"issueTrackerUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"issueNumberRegex": {
|
||||
"type": "string"
|
||||
},
|
||||
"chatDestination": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,6 +23,9 @@
|
|||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
Loading…
Reference in New Issue