Merge pull request 'refs #4975 Added chat/send in mdbVersion/upload' (!1295) from 4975-mdbConfig-and-upload into master
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1295
This commit is contained in:
commit
d30f471bc5
|
@ -26,6 +26,11 @@ module.exports = Self => {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
description: `The old version number`
|
description: `The old version number`
|
||||||
|
}, {
|
||||||
|
arg: 'description',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: `The description of changes`
|
||||||
}, {
|
}, {
|
||||||
arg: 'unlock',
|
arg: 'unlock',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
@ -42,8 +47,7 @@ module.exports = Self => {
|
||||||
verb: 'POST'
|
verb: 'POST'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Self.upload = async(ctx, options) => {
|
||||||
Self.upload = async(ctx, appName, toVersion, branch, fromVersion, unlock, options) => {
|
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
const $t = ctx.req.__; // $translate
|
const $t = ctx.req.__; // $translate
|
||||||
|
@ -51,6 +55,12 @@ module.exports = Self => {
|
||||||
const AccessContainer = models.AccessContainer;
|
const AccessContainer = models.AccessContainer;
|
||||||
const fileOptions = {};
|
const fileOptions = {};
|
||||||
let tx;
|
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')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
@ -132,13 +142,46 @@ module.exports = Self => {
|
||||||
await fs.symlink(rootRelative, destinationRoot);
|
await fs.symlink(rootRelative, destinationRoot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (description) {
|
||||||
|
let formatDesc;
|
||||||
|
const mainBranches = new Set(['master', 'test', 'dev']);
|
||||||
|
if (mainBranches.has(branch))
|
||||||
|
formatDesc = `> :branch_${branch}: `;
|
||||||
|
else
|
||||||
|
formatDesc = `> :branch: `;
|
||||||
|
|
||||||
|
formatDesc += `*${appName.toUpperCase()}* v.${toVersion} `;
|
||||||
|
|
||||||
|
const oldVersion = await models.MdbVersionTree.findOne({
|
||||||
|
where: {version: fromVersion},
|
||||||
|
fields: ['branchFk']
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
|
if (branch == oldVersion.branchFk)
|
||||||
|
formatDesc += `[*${branch}*]: `;
|
||||||
|
else
|
||||||
|
formatDesc += `[*${oldVersion.branchFk}* » *${branch}*]: `;
|
||||||
|
|
||||||
|
const params = await models.MdbConfig.findOne(myOptions);
|
||||||
|
const issueTrackerUrl = params.issueTrackerUrl;
|
||||||
|
const issueNumberRegex = params.issueNumberRegex;
|
||||||
|
const chatDestination = params.chatDestination;
|
||||||
|
|
||||||
|
const regex = new RegExp(issueNumberRegex, 'g');
|
||||||
|
formatDesc += description.replace(regex, (match, issueId) => {
|
||||||
|
const newUrl = issueTrackerUrl.replace('{index}', issueId);
|
||||||
|
return `[#${issueId}](${newUrl})`;
|
||||||
|
});
|
||||||
|
|
||||||
|
await models.Chat.send(ctx, chatDestination, formatDesc, myOptions);
|
||||||
|
}
|
||||||
await models.MdbVersionTree.create({
|
await models.MdbVersionTree.create({
|
||||||
app: appName,
|
app: appName,
|
||||||
version: toVersion,
|
version: toVersion,
|
||||||
branchFk: branch,
|
branchFk: branch,
|
||||||
fromVersion,
|
fromVersion,
|
||||||
userFk: userId
|
userFk: userId,
|
||||||
|
description,
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
await models.MdbVersion.upsert({
|
await models.MdbVersion.upsert({
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
"MdbVersionTree": {
|
"MdbVersionTree": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"MdbConfig": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"AccessContainer": {
|
"AccessContainer": {
|
||||||
"dataSource": "accessStorage"
|
"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": {
|
"userFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
Loading…
Reference in New Issue