ghreview 3.0.38 → 3.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [3.0.39](https://github.com/rvagg/ghreview/compare/v3.0.38...v3.0.39) (2026-11-02)
2
+
3
+ ### Trivial Changes
4
+
5
+ * **deps:** update simple-git@4 ([#101](https://github.com/rvagg/ghreview/issues/101)) ([e8111ae](https://github.com/rvagg/ghreview/commit/e8111ae9d290a7b6aeec049ec374dfaa255b58e0))
6
+
1
7
  ## [3.0.38](https://github.com/rvagg/ghreview/compare/v3.0.37...v3.0.38) (2026-11-02)
2
8
 
3
9
  ### Trivial Changes
package/lib/git.js CHANGED
@@ -1,4 +1,4 @@
1
- import simpleGit from 'simple-git'
1
+ import { simpleGit } from 'simple-git'
2
2
 
3
3
  export async function getCurrentBranch () {
4
4
  const git = simpleGit()
@@ -21,7 +21,10 @@ export async function hasReviewableChanges ({ all = false } = {}) {
21
21
  }
22
22
 
23
23
  export async function createReviewCommit (message, authorConfig, { all = false } = {}) {
24
- const git = simpleGit()
24
+ const { name, email } = authorConfig ?? {}
25
+ // user.name and user.email set both author and committer
26
+ const config = name && email ? [`user.name=${name}`, `user.email=${email}`] : []
27
+ const git = simpleGit({ config })
25
28
 
26
29
  if (all) {
27
30
  await git.add('.')
@@ -30,17 +33,7 @@ export async function createReviewCommit (message, authorConfig, { all = false }
30
33
  await git.add(['-u'])
31
34
  }
32
35
 
33
- // Set up environment for custom author if provided
34
- const env = {}
35
- if (authorConfig?.name && authorConfig?.email) {
36
- env.GIT_AUTHOR_NAME = authorConfig.name
37
- env.GIT_AUTHOR_EMAIL = authorConfig.email
38
- env.GIT_COMMITTER_NAME = authorConfig.name
39
- env.GIT_COMMITTER_EMAIL = authorConfig.email
40
- }
41
-
42
- // Create commit with optional custom author
43
- await git.env(env).commit(message)
36
+ await git.commit(message)
44
37
  }
45
38
 
46
39
  export async function pushBranch (remote, branch) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ghreview",
3
- "version": "3.0.38",
3
+ "version": "3.0.39",
4
4
  "description": "GitHub PR-based code review workflow for AI-assisted development",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -28,7 +28,7 @@
28
28
  "chalk": "^6.0.0",
29
29
  "ghauth": "^7.0.0",
30
30
  "ora": "^9.0.0",
31
- "simple-git": "^3.28.0",
31
+ "simple-git": "^4.0.2",
32
32
  "yargs": "^18.0.0"
33
33
  },
34
34
  "devDependencies": {
@@ -0,0 +1,41 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
2
+ import { execFileSync } from 'node:child_process'
3
+ import { mkdtemp, rm, appendFile } from 'node:fs/promises'
4
+ import { tmpdir } from 'node:os'
5
+ import { join } from 'node:path'
6
+ import { createReviewCommit } from '../lib/git.js'
7
+
8
+ const run = (dir, ...args) => execFileSync('git', args, { cwd: dir, encoding: 'utf8' }).trim()
9
+
10
+ describe('createReviewCommit', () => {
11
+ let dir
12
+
13
+ beforeEach(async () => {
14
+ dir = await mkdtemp(join(tmpdir(), 'ghreview-git-'))
15
+ run(dir, 'init', '-q')
16
+ run(dir, 'config', 'user.name', 'Local User')
17
+ run(dir, 'config', 'user.email', 'local@example.com')
18
+ await appendFile(join(dir, 'file.txt'), 'one\n')
19
+ run(dir, 'add', 'file.txt')
20
+ run(dir, 'commit', '-q', '-m', 'initial')
21
+ await appendFile(join(dir, 'file.txt'), 'two\n')
22
+ vi.spyOn(process, 'cwd').mockReturnValue(dir)
23
+ })
24
+
25
+ afterEach(async () => {
26
+ vi.restoreAllMocks()
27
+ await rm(dir, { recursive: true, force: true })
28
+ })
29
+
30
+ const identity = () => run(dir, 'log', '-1', '--format=%an <%ae>|%cn <%ce>|%s')
31
+
32
+ it('commits as the configured author and committer', async () => {
33
+ await createReviewCommit('review', { name: 'AI Assistant', email: 'ai@example.com' })
34
+ expect(identity()).toBe('AI Assistant <ai@example.com>|AI Assistant <ai@example.com>|review')
35
+ })
36
+
37
+ it('commits with the git identity when no author is configured', async () => {
38
+ await createReviewCommit('review')
39
+ expect(identity()).toBe('Local User <local@example.com>|Local User <local@example.com>|review')
40
+ })
41
+ })