logggai
Version:
AI-powered CLI for transforming your development work into professional content
28 lines • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCommitsSince = getCommitsSince;
const simple_git_1 = require("simple-git");
// Returns a list of commits since the given last commit hash (exclusive). If lastCommitHash is null, returns all commits.
async function getCommitsSince(lastCommitHash) {
const git = (0, simple_git_1.default)();
let options = [
'--pretty=format:%H|%an|%ad|%s',
'--date=iso'
];
if (lastCommitHash) {
options.push(`${lastCommitHash}..HEAD`);
}
try {
const log = await git.raw(['log', ...options]);
const lines = log.split('\n').filter(Boolean);
return lines.map(line => {
const [hash, author, date, message] = line.split('|');
return { hash, author, date, message };
});
}
catch (err) {
throw new Error('Failed to read git history: ' + err.message);
}
}
// TODO: Implement getLastSyncedCommit and groupCommits
//# sourceMappingURL=git.js.map