Compare commits

...

2 Commits

Author SHA1 Message Date
Guillermo Bonet db282cf74b refs #4975 Args declared into self.upload
gitea/salix/pipeline/head This commit looks good Details
2023-01-30 14:57:15 +01:00
Guillermo Bonet a59807e7fc refs #4975 Method upload now send rocket message
gitea/salix/pipeline/head There was a failure building this commit Details
2023-01-30 14:23:58 +01:00
4 changed files with 79 additions and 3 deletions

View File

@ -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({

View File

@ -11,6 +11,9 @@
"MdbVersionTree": {
"dataSource": "vn"
},
"MdbConfig": {
"dataSource": "vn"
},
"AccessContainer": {
"dataSource": "accessStorage"
}

View File

@ -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"
}
}
}

View File

@ -23,6 +23,9 @@
},
"userFk": {
"type": "number"
},
"description": {
"type": "string"
}
},
"relations": {