refs #4975 MdbVersion/upload fixes & code clean
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2023-02-28 13:45:36 +01:00
parent afef2e4d63
commit 9336d20e45
1 changed files with 15 additions and 9 deletions

View File

@ -47,7 +47,16 @@ module.exports = Self => {
verb: 'POST'
}
});
Self.upload = async(ctx, options) => {
Self.upload = async(
ctx,
options,
appName,
toVersion,
branch,
fromVersion,
description,
unlock
) => {
const models = Self.app.models;
const myOptions = {};
const $t = ctx.req.__; // $translate
@ -55,12 +64,6 @@ 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);
@ -153,11 +156,14 @@ module.exports = Self => {
formatDesc += `*${appName.toUpperCase()}* v.${toVersion} `;
const oldVersion = await models.MdbVersionTree.findOne({
where: {version: fromVersion},
where: {
version: fromVersion,
app: appName
},
fields: ['branchFk']
}, myOptions);
if (branch == oldVersion.branchFk)
if (!oldVersion || branch == oldVersion.branchFk)
formatDesc += `[*${branch}*]: `;
else
formatDesc += `[*${oldVersion.branchFk}* » *${branch}*]: `;