From 87b05e5ecd602d5f2f683f5779f885276bab2930 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Fri, 8 Oct 2021 08:50:06 -0500 Subject: [PATCH 01/15] add clean git branch commands --- Platform/Client/httpInterface.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index dd933ba67..d63937671 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -892,6 +892,10 @@ exports.newHttpInterface = function newHttpInterface() { const git = simpleGit(options) try { await git.checkout(currentBranch) + let postCheckoutCommands = ['git remote add upstream https://github.com/Superalgos/Superalgos', `git pull upstream ${currentBranch}`] + let result = await git.raw(postCheckoutCommands); + console.log(result) + } catch (err) { console.log('[ERROR] Error changing current branch to ' + currentBranch) console.log(err.stack) From 7adf7f718152a721a81d02b2d45af2b785e5014f Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Fri, 8 Oct 2021 08:54:22 -0500 Subject: [PATCH 02/15] remove git from raw commands --- Platform/Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index d63937671..5a3e88fe2 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -892,7 +892,7 @@ exports.newHttpInterface = function newHttpInterface() { const git = simpleGit(options) try { await git.checkout(currentBranch) - let postCheckoutCommands = ['git remote add upstream https://github.com/Superalgos/Superalgos', `git pull upstream ${currentBranch}`] + let postCheckoutCommands = ['remote add upstream https://github.com/Superalgos/Superalgos', `pull upstream ${currentBranch}`] let result = await git.raw(postCheckoutCommands); console.log(result) From 08d30ca3908b81e44ba83ac22b7d8c0bf20109dd Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Fri, 8 Oct 2021 09:57:10 -0500 Subject: [PATCH 03/15] adjust git commands --- Platform/Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 5a3e88fe2..b9434fd15 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -892,7 +892,7 @@ exports.newHttpInterface = function newHttpInterface() { const git = simpleGit(options) try { await git.checkout(currentBranch) - let postCheckoutCommands = ['remote add upstream https://github.com/Superalgos/Superalgos', `pull upstream ${currentBranch}`] + let postCheckoutCommands = [`pull https://github.com/Superalgos/Superalgos.git ${currentBranch}`, `pull upstream ${currentBranch}`] let result = await git.raw(postCheckoutCommands); console.log(result) From 80b6d2761116a7fc148c16e96813f391d0db49b5 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Fri, 8 Oct 2021 10:05:18 -0500 Subject: [PATCH 04/15] more adjustments --- Platform/Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index b9434fd15..63c120032 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -892,7 +892,7 @@ exports.newHttpInterface = function newHttpInterface() { const git = simpleGit(options) try { await git.checkout(currentBranch) - let postCheckoutCommands = [`pull https://github.com/Superalgos/Superalgos.git ${currentBranch}`, `pull upstream ${currentBranch}`] + let postCheckoutCommands = ['pull', `https://github.com/Superalgos/Superalgos.git ${currentBranch}`, `pull upstream ${currentBranch}`] let result = await git.raw(postCheckoutCommands); console.log(result) From baf64da77c2156565643ff3e346f3c84521f4406 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Fri, 8 Oct 2021 11:10:05 -0500 Subject: [PATCH 05/15] almost there --- Platform/Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 63c120032..4ea81d56e 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -892,7 +892,7 @@ exports.newHttpInterface = function newHttpInterface() { const git = simpleGit(options) try { await git.checkout(currentBranch) - let postCheckoutCommands = ['pull', `https://github.com/Superalgos/Superalgos.git ${currentBranch}`, `pull upstream ${currentBranch}`] + let postCheckoutCommands = ['pull', `https://github.com/Superalgos/Superalgos.git ${currentBranch}`, 'reset', `--hard https://github.com/Superalgos/Superalgos.git/${currentBranch}`] let result = await git.raw(postCheckoutCommands); console.log(result) From ae7eaad7bab7f56ffec9ee6595d70c4c64fb65b4 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 10 Oct 2021 21:52:59 -0500 Subject: [PATCH 06/15] break up git commands --- Platform/Client/httpInterface.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 4ea81d56e..34875038d 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -892,9 +892,10 @@ exports.newHttpInterface = function newHttpInterface() { const git = simpleGit(options) try { await git.checkout(currentBranch) - let postCheckoutCommands = ['pull', `https://github.com/Superalgos/Superalgos.git ${currentBranch}`, 'reset', `--hard https://github.com/Superalgos/Superalgos.git/${currentBranch}`] - let result = await git.raw(postCheckoutCommands); - console.log(result) + let postCheckoutCommands = ['pull', `https://github.com/Superalgos/Superalgos.git ${currentBranch}`] + await git.raw(postCheckoutCommands); + let updateToMainRepo = ['reset', `--hard https://github.com/Superalgos/Superalgos.git/${currentBranch}`] + await git.raw(updateToMainRepo); } catch (err) { console.log('[ERROR] Error changing current branch to ' + currentBranch) From f00d0fe5675ae06b36e8040e6a945c01b8bba40e Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 10 Oct 2021 22:01:10 -0500 Subject: [PATCH 07/15] final command setup (hopfully) --- Platform/Client/httpInterface.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 34875038d..77245ae98 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -892,9 +892,11 @@ exports.newHttpInterface = function newHttpInterface() { const git = simpleGit(options) try { await git.checkout(currentBranch) - let postCheckoutCommands = ['pull', `https://github.com/Superalgos/Superalgos.git ${currentBranch}`] - await git.raw(postCheckoutCommands); - let updateToMainRepo = ['reset', `--hard https://github.com/Superalgos/Superalgos.git/${currentBranch}`] + let setUpstream = ['remote', 'add', 'upstream', 'https://github.com/Superalgos/Superalgos'] + await git.raw(setUpstream); + let pullMainRepo = ['pull', 'upstream', `${currentBranch}`] + await git.raw(pullMainRepo); + let updateToMainRepo = ['reset', '--hard', `upstream/${currentBranch}`] await git.raw(updateToMainRepo); } catch (err) { From 2aedf8d408562d0c9a500a53a5c077b1a2a11dcb Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 10 Oct 2021 22:07:25 -0500 Subject: [PATCH 08/15] condition for setting upstream --- Platform/Client/httpInterface.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 77245ae98..5b0b76c27 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -892,8 +892,13 @@ exports.newHttpInterface = function newHttpInterface() { const git = simpleGit(options) try { await git.checkout(currentBranch) - let setUpstream = ['remote', 'add', 'upstream', 'https://github.com/Superalgos/Superalgos'] - await git.raw(setUpstream); + + let remotes = await git.getRemotes(); + if (true){ + console.log(remotes) + let setUpstream = ['remote', 'add', 'upstream', 'https://github.com/Superalgos/Superalgos'] + //await git.getRemotes(setUpstream); + } let pullMainRepo = ['pull', 'upstream', `${currentBranch}`] await git.raw(pullMainRepo); let updateToMainRepo = ['reset', '--hard', `upstream/${currentBranch}`] From b259db992ef90c484ca0265712507daf48a64dfb Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 10 Oct 2021 22:12:03 -0500 Subject: [PATCH 09/15] more changes --- Platform/Client/httpInterface.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 5b0b76c27..b072eab8f 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -894,15 +894,18 @@ exports.newHttpInterface = function newHttpInterface() { await git.checkout(currentBranch) let remotes = await git.getRemotes(); + for(let remote in remotes) { + console.log(remote) + } if (true){ - console.log(remotes) + //console.log(remotes) let setUpstream = ['remote', 'add', 'upstream', 'https://github.com/Superalgos/Superalgos'] //await git.getRemotes(setUpstream); } let pullMainRepo = ['pull', 'upstream', `${currentBranch}`] - await git.raw(pullMainRepo); + //await git.raw(pullMainRepo); let updateToMainRepo = ['reset', '--hard', `upstream/${currentBranch}`] - await git.raw(updateToMainRepo); + //await git.raw(updateToMainRepo); } catch (err) { console.log('[ERROR] Error changing current branch to ' + currentBranch) From 2f889aa341812a21a3aa04a0d2f879b6e3761014 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 10 Oct 2021 22:14:35 -0500 Subject: [PATCH 10/15] adjust getting remotes --- Platform/Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index b072eab8f..f133ab57e 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -895,7 +895,7 @@ exports.newHttpInterface = function newHttpInterface() { let remotes = await git.getRemotes(); for(let remote in remotes) { - console.log(remote) + console.log(remote.name) } if (true){ //console.log(remotes) From bafd07ab9dfe5eeeb3ce69fbf1adbe0d275501dd Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Mon, 11 Oct 2021 07:29:32 -0500 Subject: [PATCH 11/15] fix access remote names object --- Platform/Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index f133ab57e..287a13bcc 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -895,7 +895,7 @@ exports.newHttpInterface = function newHttpInterface() { let remotes = await git.getRemotes(); for(let remote in remotes) { - console.log(remote.name) + console.log(remotes[remote].name) } if (true){ //console.log(remotes) From bca61923273164dcd2b29f95d7e31e0e63a379ce Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Mon, 11 Oct 2021 07:44:57 -0500 Subject: [PATCH 12/15] final command adjustments --- Platform/Client/httpInterface.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 287a13bcc..d18c7619f 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -893,19 +893,25 @@ exports.newHttpInterface = function newHttpInterface() { try { await git.checkout(currentBranch) + // Check to see it main repo has been set as upstream let remotes = await git.getRemotes(); for(let remote in remotes) { - console.log(remotes[remote].name) + let isUpstreamSet + if (remotes[remote].name === upstream) { + isUpstreamSet = true + } else { + isUpstreamSet = false + } } - if (true){ - //console.log(remotes) - let setUpstream = ['remote', 'add', 'upstream', 'https://github.com/Superalgos/Superalgos'] - //await git.getRemotes(setUpstream); + // If upstream has not been set. Set it now + if (isUpstreamSet === false){ + await git.addRemote('upstream', 'https://github.com/Superalgos/Superalgos'); } - let pullMainRepo = ['pull', 'upstream', `${currentBranch}`] - //await git.raw(pullMainRepo); - let updateToMainRepo = ['reset', '--hard', `upstream/${currentBranch}`] - //await git.raw(updateToMainRepo); + // Pull branch from main repo + await git.pull('upstream', currentBranch); + // Reset branch to match main repo + let upstreamLocation = `upstream/${currentBranch}` + await git.reset('hard', [upstreamLocation]) } catch (err) { console.log('[ERROR] Error changing current branch to ' + currentBranch) From 9469f4293c8c6a7d8994e6dd62c9de92a4e6c0a8 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Mon, 11 Oct 2021 07:46:58 -0500 Subject: [PATCH 13/15] type fix --- Platform/Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index d18c7619f..511db7069 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -897,7 +897,7 @@ exports.newHttpInterface = function newHttpInterface() { let remotes = await git.getRemotes(); for(let remote in remotes) { let isUpstreamSet - if (remotes[remote].name === upstream) { + if (remotes[remote].name === 'upstream') { isUpstreamSet = true } else { isUpstreamSet = false From 1bc5e34c9d053d9cb557ff729c40cba97d850308 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Mon, 11 Oct 2021 07:48:59 -0500 Subject: [PATCH 14/15] fix variable scope --- Platform/Client/httpInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index 511db7069..a3ca61472 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -895,8 +895,8 @@ exports.newHttpInterface = function newHttpInterface() { // Check to see it main repo has been set as upstream let remotes = await git.getRemotes(); + let isUpstreamSet for(let remote in remotes) { - let isUpstreamSet if (remotes[remote].name === 'upstream') { isUpstreamSet = true } else { From 67886ead733ddb531ece0203bc310925e57cf578 Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Mon, 11 Oct 2021 08:01:46 -0500 Subject: [PATCH 15/15] clean code and move required modules to platformRoot --- Platform/Client/httpInterface.js | 11 +++++------ PlatformRoot.js | 4 +++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Platform/Client/httpInterface.js b/Platform/Client/httpInterface.js index a3ca61472..a09c0294f 100644 --- a/Platform/Client/httpInterface.js +++ b/Platform/Client/httpInterface.js @@ -922,18 +922,17 @@ exports.newHttpInterface = function newHttpInterface() { async function runNodeSetup () { console.log( "Running Node setup to adjust for new Branch" ) - const process = require("process"); - const { execSync } = require("child_process"); + const process = SA.nodeModules.process + const childProcess = SA.nodeModules.childProcess let dir = process.cwd() - let command = "node setup"; - let stdout = execSync( command, + let command = "node setup noShortcuts"; + let stdout = childProcess.execSync( command, { cwd: dir }).toString(); - console.log("Node Setup has completed with the following result:", stdout) - + console.log("Node Setup has completed with the following result:", stdout) } } catch (err) { diff --git a/PlatformRoot.js b/PlatformRoot.js index 396a1c727..924c9e1e5 100644 --- a/PlatformRoot.js +++ b/PlatformRoot.js @@ -48,7 +48,9 @@ SA.nodeModules = { ccxt: require('ccxt'), octokit: require("@octokit/rest"), simpleGit: require('simple-git'), - lookpath: require('lookpath') + lookpath: require('lookpath'), + process: require('process'), + childProcess: require('child_process') } run()