Final implementations of Git Branches
This commit is contained in:
1 parent
29fe73b3c8
commit
8b247f7af9
4 files changed
+88
-11
No files matched your search
+51
-8
@@ -533,6 +533,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
const commitMessage = unescape(requestParameters[3])
|
||||
const username = unescape(requestParameters[4])
|
||||
const token = unescape(requestParameters[5])
|
||||
const activeBranch = unescape(requestParameters[6])
|
||||
const contributionsBranch = unescape(requestParameters[7])
|
||||
|
||||
contribute()
|
||||
|
||||
@@ -553,7 +555,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
|
||||
await git.add('./*')
|
||||
await git.commit(commitMessage)
|
||||
await git.push('origin', 'in-app-documentation')
|
||||
await git.push('origin', branch)
|
||||
}
|
||||
|
||||
async function doGithub() {
|
||||
@@ -567,8 +569,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
|
||||
const repo = 'Superalgos'
|
||||
const owner = 'Superalgos'
|
||||
const head = username + ':in-app-documentation'
|
||||
const base = 'in-app-documentation'
|
||||
const head = username + ':' + contributionsBranch
|
||||
const base = activeBranch
|
||||
const title = 'Contribution: ' + commitMessage
|
||||
|
||||
try {
|
||||
@@ -604,10 +606,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
}
|
||||
case 'Update': {
|
||||
try {
|
||||
const message = unescape(requestParameters[3])
|
||||
const username = unescape(requestParameters[4])
|
||||
const token = unescape(requestParameters[5])
|
||||
|
||||
const activeBranch = unescape(requestParameters[3])
|
||||
update()
|
||||
|
||||
async function update() {
|
||||
@@ -629,7 +628,51 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
}
|
||||
const git = simpleGit(options)
|
||||
|
||||
return await git.pull('upstream', 'in-app-documentation')
|
||||
return await git.pull('upstream', activeBranch)
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> Method call produced an error.')
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> err.stack = ' + err.stack)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> commitMessage = ' + commitMessage)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> username = ' + username)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> token = ' + token)
|
||||
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
message: err.message,
|
||||
stack: err.stack
|
||||
}
|
||||
respondWithContent(JSON.stringify(error), httpResponse)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'Checkout': {
|
||||
try {
|
||||
const activeBranch = unescape(requestParameters[3])
|
||||
checkout()
|
||||
|
||||
async function checkout() {
|
||||
let message = await doGit()
|
||||
|
||||
let customResponse = {
|
||||
result: global.CUSTOM_OK_RESPONSE.result,
|
||||
message: message
|
||||
}
|
||||
respondWithContent(JSON.stringify(customResponse), httpResponse)
|
||||
}
|
||||
|
||||
async function doGit() {
|
||||
const simpleGit = require('simple-git');
|
||||
const options = {
|
||||
baseDir: process.cwd(),
|
||||
binary: 'git',
|
||||
maxConcurrentProcesses: 6,
|
||||
}
|
||||
const git = simpleGit(options)
|
||||
|
||||
return await git.checkoutBranch(activeBranch)
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"topic": "Branches Management Messages",
|
||||
"pageNumber": "4",
|
||||
"type": "Switching Branches - Active Branch Not Changed",
|
||||
"definition": {
|
||||
"text": "Write here a summary for this topic page."
|
||||
},
|
||||
"paragraphs": [
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -62,7 +62,16 @@ function newSuperalgosDocsCommmandInterface() {
|
||||
return
|
||||
}
|
||||
|
||||
httpRequest(undefined, 'App/Contribute/' + message + '/' + config.username + '/' + config.token, onResponse)
|
||||
httpRequest(
|
||||
undefined,
|
||||
'App/Contribute/' +
|
||||
message + '/' +
|
||||
config.username + '/' +
|
||||
config.token + '/' +
|
||||
UI.projects.superalgos.spaces.docsSpace.activeBranch + '/' +
|
||||
UI.projects.superalgos.spaces.docsSpace.contributionBranch
|
||||
, onResponse)
|
||||
|
||||
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message - Creating Pull Request')
|
||||
|
||||
return
|
||||
@@ -112,7 +121,7 @@ function newSuperalgosDocsCommmandInterface() {
|
||||
return
|
||||
}
|
||||
|
||||
httpRequest(undefined, 'App/Update/' + message + '/' + config.username + '/' + config.token, onResponse)
|
||||
httpRequest(undefined, 'App/Update/' + UI.projects.superalgos.spaces.docsSpace.activeBranch, onResponse)
|
||||
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message - Updating Your Local App')
|
||||
|
||||
return
|
||||
|
||||
@@ -185,9 +185,20 @@ function newSuperalgosDocSpace() {
|
||||
}
|
||||
|
||||
function changeActiveBranch(branch) {
|
||||
UI.projects.superalgos.spaces.docsSpace.activeBranch = branch
|
||||
window.localStorage.setItem('Active Branch', UI.projects.superalgos.spaces.docsSpace.activeBranch)
|
||||
httpRequest(undefined, 'App/Checkout/' + UI.projects.superalgos.spaces.docsSpace.activeBranch, onResponse)
|
||||
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Changing Active Branch')
|
||||
|
||||
function onResponse(err, data) {
|
||||
/* Lets check the result of the call through the http interface */
|
||||
data = JSON.parse(data)
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.CUSTOM_OK_RESPONSE.result) {
|
||||
UI.projects.superalgos.spaces.docsSpace.activeBranch = branch
|
||||
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Active Branch Changed')
|
||||
} else {
|
||||
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Active Branch Not Changed')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changeContributionsBranch(branch) {
|
||||
|
||||
Reference in new issue
Block a user