Skip to content

Commit

Permalink
Finished Git additions
Browse files Browse the repository at this point in the history
  • Loading branch information
Mewantha committed Apr 15, 2022
1 parent 829f5c3 commit 6aca351
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions controllers/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,23 @@
var fs = require('fs');

exports.postCommit = (req, res, next) => {
console.log(req.body);
const commitText = req.body.commitText;
//Commit(commitText).
var execProcess = require("./exec_process.js");
execProcess.result("git clone https://github.com/Phantom-Intruder/site.git & git checkout -b topic/work-on-site", (err, response) => {
execProcess.result("git clone https://github.com/Phantom-Intruder/site.git & git checkout -b topic/work-on-site", (err) => {
if (err){
execProcess.result("cd ../site & git checkout -b topic/work-on-site & git pull origin topic/work-on-site", (err, response) => {
execProcess.result("cd site & git checkout topic/work-on-site & git reset --hard & git pull origin topic/work-on-site", (err) => {
if(!err){
console.log(response);
//console.log(response);
var logStream = fs.createWriteStream('site/src/app/app.component.html', {flags: 'a'});
logStream.write('<br/><p>This is a commit block</p>');
execProcess.result('cd ../site & git add . & git commit -m "New block commited." & git push -u origin topic/work-on-site', (err, response) => {
if(!err){
console.log(response);
} else {
console.log(err);
}
});
changeFileAndCommit(execProcess, commitText);
}else {
console.log(err);
console.log("There was an err in method")
return err
//console.log(err);
return err;
}
})
} else {
changeFileAndCommit(execProcess, commitText);
}
})
.then(value => {
Expand All @@ -39,9 +31,14 @@ exports.postCommit = (req, res, next) => {
})
}

performGitCommand = (command) => {
if (shell.exec(command).code !== 0) {
shell.echo('Error: Git commit failed');
shell.exit(1);
}
}
changeFileAndCommit = (execProcess, commitText) => {
var logStream = fs.createWriteStream('site/src/app/app.component.html', { flags: 'a' });
logStream.write('<br/><p>' + commitText + '</p>');
execProcess.result('cd site & git commit -am "New block commited." & git push -u origin topic/work-on-site', (err, response) => {
if (!err) {
console.log(response);
} else {
console.log(err);
}
});
}

0 comments on commit 6aca351

Please sign in to comment.