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",