feat: history browse diffs

This commit is contained in:
NGPixel
2017-07-06 00:10:41 -04:00
committed by Nicolas Giard
parent fa1f332057
commit 20a2e0e3ce
6 changed files with 93 additions and 34 deletions

View File

@@ -265,7 +265,7 @@ module.exports = {
let self = this
let gitFilePath = entryPath + '.md'
return self._git.exec('log', ['-n', '25', '--format=format:%H %h %cI %cE %cN', '--', gitFilePath]).then((cProc) => {
return self._git.exec('log', ['--max-count=25', '--skip=1', '--format=format:%H %h %cI %cE %cN', '--', gitFilePath]).then((cProc) => {
let out = cProc.stdout.toString()
if (_.includes(out, 'fatal')) {
let errorMsg = _.capitalize(_.head(_.split(_.replace(out, 'fatal: ', ''), ',')))
@@ -286,6 +286,24 @@ module.exports = {
}).value()
return hist
})
},
getHistoryDiff(path, commit, comparewith) {
let self = this
if (!comparewith) {
comparewith = 'HEAD'
}
return self._git.exec('diff', ['--no-color', `${commit}:${path}.md`, `${comparewith}:${path}.md`]).then((cProc) => {
let out = cProc.stdout.toString()
if (_.startsWith(out, 'fatal: ')) {
throw new Error(out)
} else if (!_.includes(out, 'diff')) {
throw new Error('Unable to query diff data.')
} else {
return out
}
})
}
}