humpty
Version:
Makes sure your changelogs mention your breaking changes
30 lines (23 loc) • 763 B
JavaScript
let storedCommits;
let storedFiles = {};
function SimpleGitMock(repoPath) {
this.repoPath = repoPath;
this.log = (opts, callback) => {
callback(undefined, { all: storedCommits });
};
this.show = ([showRequest], callback) => {
const [sha, fileName] = showRequest.split(":");
if (storedFiles[sha] && storedFiles[sha][fileName]) {
callback(undefined, storedFiles[sha][fileName]);
} else {
callback(`Fatal error: could not show ${fileName}`);
}
};
}
const simpleGit = function(repoPath) {
return new SimpleGitMock(repoPath);
};
simpleGit.__setCommits__ = commits =>
(storedCommits = commits.map(commit => ({ message: commit })));
simpleGit.__setFiles__ = files => (storedFiles = files);
module.exports = simpleGit;