Allow unstaged files to be reverted

This commit is contained in:
Nick O'Leary
2017-12-11 17:05:12 +00:00
parent 604e3068b2
commit bb59cd5742
8 changed files with 180 additions and 81 deletions

View File

@@ -329,6 +329,14 @@ Project.prototype.getFile = function (filePath,treeish) {
return fs.readFile(fspath.join(this.path,filePath),"utf8");
}
};
Project.prototype.revertFile = function (filePath) {
var self = this;
return gitTools.revertFile(this.path, filePath).then(function() {
return self.load();
});
};
Project.prototype.status = function(user) {
var self = this;

View File

@@ -421,6 +421,10 @@ module.exports = {
return status.files;
})
},
revertFile: function(cwd, filePath) {
var args = ["checkout",filePath];
return runGitCommand(args,cwd);
},
stageFile: function(cwd,file) {
var args = ["add"];
if (Array.isArray(file)) {

View File

@@ -173,7 +173,7 @@ function getFileDiff(user, project,file,type) {
}
function getCommits(user, project,options) {
checkActiveProject(project);
return activeProject.getCommits(options);
return activeProject.getCommits(options);
}
function getCommit(user, project,sha) {
checkActiveProject(project);
@@ -184,6 +184,12 @@ function getFile(user, project,filePath,sha) {
checkActiveProject(project);
return activeProject.getFile(filePath,sha);
}
function revertFile(user, project,filePath) {
checkActiveProject(project);
return activeProject.revertFile(filePath).then(function() {
return reloadActiveProject("revert");
})
}
function push(user, project,remoteBranchName,setRemote) {
checkActiveProject(project);
return activeProject.push(user,remoteBranchName,setRemote);
@@ -413,6 +419,7 @@ module.exports = {
updateProject: updateProject,
getFiles: getFiles,
getFile: getFile,
revertFile: revertFile,
stageFile: stageFile,
unstageFile: unstageFile,
commit: commit,