ai-cmg 0.0.6 → 0.0.7

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -96,9 +96,16 @@ async function runConfigCommand(args) {
96
96
  console.log('No changes made.');
97
97
  }
98
98
  }
99
+ function getGitEnv() {
100
+ const env = { ...process.env };
101
+ delete env.GIT_DIR;
102
+ delete env.GIT_WORK_TREE;
103
+ delete env.GIT_CEILING_DIRECTORIES;
104
+ return env;
105
+ }
99
106
  function resolveRepoRoot() {
100
107
  try {
101
- const root = execSync('git rev-parse --show-toplevel').toString().trim();
108
+ const root = execSync('git rev-parse --show-toplevel', { env: getGitEnv() }).toString().trim();
102
109
  return root || null;
103
110
  }
104
111
  catch {
@@ -141,7 +148,10 @@ function parseMessageArgs(rawArgs) {
141
148
  function getNameStatus(repoRoot) {
142
149
  const map = new Map();
143
150
  try {
144
- const output = execSync('git diff --cached --name-status', { cwd: repoRoot }).toString();
151
+ const output = execSync('git diff --cached --name-status', {
152
+ cwd: repoRoot,
153
+ env: getGitEnv()
154
+ }).toString();
145
155
  output.split('\n').forEach((line) => {
146
156
  if (!line.trim())
147
157
  return;
@@ -158,7 +168,10 @@ function getNameStatus(repoRoot) {
158
168
  }
159
169
  function getChangedFiles(repoRoot) {
160
170
  try {
161
- const output = execSync('git status --porcelain -z', { cwd: repoRoot }).toString();
171
+ const output = execSync('git status --porcelain -z', {
172
+ cwd: repoRoot,
173
+ env: getGitEnv()
174
+ }).toString();
162
175
  if (!output)
163
176
  return [];
164
177
  const parts = output.split('\0').filter(Boolean);
@@ -216,7 +229,7 @@ async function promptStageFiles(repoRoot) {
216
229
  if (action === 'cancel')
217
230
  return false;
218
231
  if (action === 'all') {
219
- spawnSync('git', ['add', '.'], { stdio: 'inherit', cwd: repoRoot });
232
+ spawnSync('git', ['add', '.'], { stdio: 'inherit', cwd: repoRoot, env: getGitEnv() });
220
233
  return true;
221
234
  }
222
235
  const fileChoices = candidates.map((entry) => ({
@@ -233,7 +246,7 @@ async function promptStageFiles(repoRoot) {
233
246
  const files = picked.files;
234
247
  if (!files || files.length === 0)
235
248
  return false;
236
- spawnSync('git', ['add', '--', ...files], { stdio: 'inherit', cwd: repoRoot });
249
+ spawnSync('git', ['add', '--', ...files], { stdio: 'inherit', cwd: repoRoot, env: getGitEnv() });
237
250
  return true;
238
251
  }
239
252
  function getExtension(filePath) {
@@ -356,7 +369,7 @@ async function main() {
356
369
  // 3. Git Diff 가져오기
357
370
  let diff;
358
371
  try {
359
- diff = execSync('git diff --cached', { cwd: repoRoot }).toString();
372
+ diff = execSync('git diff --cached', { cwd: repoRoot, env: getGitEnv() }).toString();
360
373
  }
361
374
  catch (e) {
362
375
  console.log('Error: not a git repository or git is unavailable.');
@@ -366,7 +379,7 @@ async function main() {
366
379
  const staged = await promptStageFiles(repoRoot);
367
380
  if (!staged)
368
381
  return;
369
- diff = execSync('git diff --cached', { cwd: repoRoot }).toString();
382
+ diff = execSync('git diff --cached', { cwd: repoRoot, env: getGitEnv() }).toString();
370
383
  if (!diff.trim()) {
371
384
  console.log('No staged changes. Nothing to commit.');
372
385
  return;
@@ -425,11 +438,11 @@ async function main() {
425
438
  const action = actions[choice - 1].value;
426
439
  switch (action) {
427
440
  case 'commit':
428
- spawnSync('git', ['commit', '-m', message], { stdio: 'inherit', cwd: repoRoot });
441
+ spawnSync('git', ['commit', '-m', message], { stdio: 'inherit', cwd: repoRoot, env: getGitEnv() });
429
442
  console.log('Commit complete.');
430
443
  break;
431
444
  case 'edit':
432
- spawnSync('git', ['commit', '-e', '-m', message], { stdio: 'inherit', cwd: repoRoot });
445
+ spawnSync('git', ['commit', '-e', '-m', message], { stdio: 'inherit', cwd: repoRoot, env: getGitEnv() });
433
446
  console.log('Commit complete.');
434
447
  break;
435
448
  case 'copy':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-cmg",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "AI Commit Message Generator",
5
5
  "type": "module",
6
6
  "bin": {