mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add commit history view in sidebar
This commit is contained in:
@@ -173,6 +173,28 @@ function getFiles(localRepo) {
|
||||
})
|
||||
}
|
||||
|
||||
function parseLog(log) {
|
||||
var lines = log.split("\n");
|
||||
var currentCommit = null;
|
||||
var commits = [];
|
||||
lines.forEach(function(l) {
|
||||
if (/^sha: /.test(l)) {
|
||||
if (currentCommit) {
|
||||
commits.push(currentCommit);
|
||||
}
|
||||
currentCommit = {}
|
||||
}
|
||||
var m = /^(.*): (.*)$/.exec(l);
|
||||
if (m) {
|
||||
currentCommit[m[1]] = m[2];
|
||||
}
|
||||
});
|
||||
if (currentCommit) {
|
||||
commits.push(currentCommit);
|
||||
}
|
||||
return {commits: commits};
|
||||
}
|
||||
|
||||
var gitCommand = "git";
|
||||
module.exports = {
|
||||
initRepo: function(cwd) {
|
||||
@@ -219,5 +241,13 @@ module.exports = {
|
||||
}
|
||||
args.push(file);
|
||||
return runCommand(gitCommand,args,cwd);
|
||||
},
|
||||
getCommits: function(cwd,options) {
|
||||
var args = ["log", "--format=sha: %H%nauthor: %an%ndate: %ct%nsubject: %s","-n 10"];
|
||||
return runCommand(gitCommand,args,cwd).then(parseLog);
|
||||
},
|
||||
getCommit: function(cwd,sha) {
|
||||
var args = ["show",sha];
|
||||
return runCommand(gitCommand,args,cwd);
|
||||
}
|
||||
}
|
||||
|
@@ -355,6 +355,15 @@ function getFileDiff(project,file,type) {
|
||||
var projectPath = fspath.join(projectsDir,project);
|
||||
return gitTools.getFileDiff(projectPath,file,type);
|
||||
}
|
||||
function getCommits(project,options) {
|
||||
var projectPath = fspath.join(projectsDir,project);
|
||||
return gitTools.getCommits(projectPath,options);
|
||||
}
|
||||
function getCommit(project,sha) {
|
||||
var projectPath = fspath.join(projectsDir,project);
|
||||
return gitTools.getCommit(projectPath,sha);
|
||||
}
|
||||
|
||||
function getFile(project,path) {
|
||||
|
||||
}
|
||||
@@ -512,6 +521,8 @@ module.exports = {
|
||||
unstageFile: unstageFile,
|
||||
commit: commit,
|
||||
getFileDiff: getFileDiff,
|
||||
getCommits: getCommits,
|
||||
getCommit: getCommit,
|
||||
|
||||
getFlows: getFlows,
|
||||
saveFlows: saveFlows,
|
||||
|
Reference in New Issue
Block a user