From af909047ae7936242a82fd07719723f2184356ab Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sat, 22 Jun 2024 10:01:15 +0200 Subject: [PATCH] fix(core): update --- test/test.ts | 14 ++++++++++++++ ts/00_commitinfo_data.ts | 2 +- ts/smartgit.classes.gitrepo.ts | 11 +++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/test/test.ts b/test/test.ts index 3869426..ae3b4e6 100644 --- a/test/test.ts +++ b/test/test.ts @@ -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(); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index df2bd77..bd432a1 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -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.' } diff --git a/ts/smartgit.classes.gitrepo.ts b/ts/smartgit.classes.gitrepo.ts index 00600e9..c95f70c 100644 --- a/ts/smartgit.classes.gitrepo.ts +++ b/ts/smartgit.classes.gitrepo.ts @@ -172,4 +172,15 @@ export class GitRepo { return diffs; } + + /** + * Get all commit messages + */ + public async getAllCommitMessages(): Promise { + const commits = await plugins.isomorphicGit.log({ + fs: this.smartgitRef.envDeps.fs, + dir: this.repoDir, + }); + return commits.map(commit => commit.commit.message); + } }