From a8a9aac53610aa9ad2733d72dcaeadd7711c2a6f Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 16 Feb 2023 11:06:58 +0100 Subject: [PATCH] push command fix: apply views at the end --- myt-push.js | 25 ++++++++++++++----------- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/myt-push.js b/myt-push.js index 856fd14..dfd032c 100644 --- a/myt-push.js +++ b/myt-push.js @@ -267,8 +267,7 @@ class Push extends Command { const gitExists = await fs.pathExists(`${opts.workspace}/.git`); let nRoutines = 0; - let changes = await this.changedRoutines(version.gitCommit); - changes = this.parseChanges(changes); + const changes = await this.changedRoutines(version.gitCommit); const routines = []; for (const change of changes) @@ -397,14 +396,6 @@ class Push extends Command { await pushConn.end(); } - parseChanges(changes) { - const routines = []; - if (changes) - for (const change of changes) - routines.push(new Routine(change)); - return routines; - } - async updateVersion(column, value) { column = SqlString.escapeId(column, true); await this.conn.query( @@ -478,9 +469,21 @@ class Push extends Command { await pushChanges(await repoExt.getUnstaged(repo)); await pushChanges(await repoExt.getStaged(repo)); - return changes.sort((a, b) => { + const routines = []; + for (const change of changes) + routines.push(new Routine(change)); + + return routines.sort((a, b) => { if (b.mark != a.mark) return b.mark == '-' ? 1 : -1; + + if (b.type.name !== a.type.name) { + if (b.type.name == 'VIEW') + return -1; + if (a.type.name == 'VIEW') + return 1; + } + return a.path.localeCompare(b.path); }); } diff --git a/package-lock.json b/package-lock.json index a95220c..8c5c349 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@verdnatura/myt", - "version": "1.5.13", + "version": "1.5.14", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@verdnatura/myt", - "version": "1.5.13", + "version": "1.5.14", "license": "GPL-3.0", "dependencies": { "@sqltools/formatter": "^1.2.5", diff --git a/package.json b/package.json index 8dff473..a1ee400 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@verdnatura/myt", - "version": "1.5.13", + "version": "1.5.14", "author": "Verdnatura Levante SL", "description": "MySQL version control", "license": "GPL-3.0",