Add unified diff view to version control tab

This commit is contained in:
Nick O'Leary
2017-10-09 00:11:07 +01:00
parent 51bad3bf3c
commit 10567afbb9
6 changed files with 185 additions and 14 deletions

View File

@@ -188,6 +188,21 @@ module.exports = {
})
});
app.get(/([^\/]+)\/diff\/([^\/]+)\/(.+)$/, function(req,res) {
var projectName = req.params[0];
var type = req.params[1];
var file = req.params[2];
runtime.storage.projects.getFileDiff(projectName,file,type).then(function(data) {
res.json({
diff: data
})
})
.catch(function(err) {
console.log(err.stack);
res.status(400).json({error:"unexpected_error", message:err.toString()});
})
});
app.get(new RegExp("/([^\/]+)\/files\/(.*)"), function(req,res) {
// Get project file
});

View File

@@ -209,5 +209,15 @@ module.exports = {
commit: function(cwd, message) {
var args = ["commit","-m",message];
return runCommand(gitCommand,args,cwd);
},
getFileDiff(cwd,file,type) {
var args = ["diff"];
if (type === "tree") {
// nothing else to do
} else if (type === "index") {
args.push("--cached");
}
args.push(file);
return runCommand(gitCommand,args,cwd);
}
}

View File

@@ -351,6 +351,10 @@ function commit(project,options) {
var projectPath = fspath.join(projectsDir,project);
return gitTools.commit(projectPath,options.message);
}
function getFileDiff(project,file,type) {
var projectPath = fspath.join(projectsDir,project);
return gitTools.getFileDiff(projectPath,file,type);
}
function getFile(project,path) {
}
@@ -507,6 +511,7 @@ module.exports = {
stageFile: stageFile,
unstageFile: unstageFile,
commit: commit,
getFileDiff: getFileDiff,
getFlows: getFlows,
saveFlows: saveFlows,