Compare commits

...

2 Commits

Author SHA1 Message Date
a5dae9b3a3 3.0.4 2024-06-22 10:01:16 +02:00
af909047ae fix(core): update 2024-06-22 10:01:15 +02:00
4 changed files with 27 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@push.rocks/smartgit",
"version": "3.0.3",
"version": "3.0.4",
"description": "A smart wrapper for nodegit that simplifies Git operations in Node.js.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",

View File

@ -34,4 +34,18 @@ tap.test('should open a repo', async () => {
console.log(diff);
});
tap.test('should get the diff to HEAD', async () => {
const gitRepo = await testSmartgitInstance.createRepoByOpen(packageDir);
const diff = await gitRepo.getUncommittedDiff([
'pnpm-lock.yaml',
]);
console.log(diff);
});
tap.test('should print all commit messages', async () => {
const gitRepo = await testSmartgitInstance.createRepoByOpen(packageDir);
const commitMessages = await gitRepo.getAllCommitMessages();
console.log(commitMessages);
});
await tap.start();

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartgit',
version: '3.0.3',
version: '3.0.4',
description: 'A smart wrapper for nodegit that simplifies Git operations in Node.js.'
}

View File

@ -172,4 +172,15 @@ export class GitRepo {
return diffs;
}
/**
* Get all commit messages
*/
public async getAllCommitMessages(): Promise<string[]> {
const commits = await plugins.isomorphicGit.log({
fs: this.smartgitRef.envDeps.fs,
dir: this.repoDir,
});
return commits.map(commit => commit.commit.message);
}
}