ai-git-tools 2.0.37 → 2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-git-tools",
3
- "version": "2.0.37",
3
+ "version": "2.0.39",
4
4
  "description": "AI-powered Git automation tools for commit messages and PR generation",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -35,7 +35,7 @@ export class GitOperations {
35
35
  const branches = this.detectReleaseBranches();
36
36
  if (branches.length === 0) return null;
37
37
 
38
- // 優先選月分支(-m),其次週分支(-w),最後 fallback 到全部 release 分支
38
+ // 優先選月分支(-m),其次週分支(-w),最後 fallback 到全部 release 分支
39
39
  const monthlyBranches = branches.filter((b) => b.includes('-m'));
40
40
  const weeklyBranches = branches.filter((b) => b.includes('-w'));
41
41
  const priorityBranches =
@@ -145,9 +145,27 @@ export class GitOperations {
145
145
  */
146
146
  async push(branch) {
147
147
  try {
148
- execSync(`git push -u origin ${branch}`, { stdio: 'inherit' });
148
+ execSync(`git push -u origin ${branch}`, {
149
+ stdio: ['ignore', 'inherit', 'pipe'],
150
+ encoding: 'utf-8',
151
+ });
149
152
  return true;
150
153
  } catch (error) {
154
+ const errMsg = (error.stderr || error.message || '').toString();
155
+ const is403 = errMsg.includes('403') || errMsg.includes('Write access') || errMsg.includes('write access');
156
+ if (is403) {
157
+ throw new PRError(
158
+ '\u63a8送失敗:git 沒有寫入權限',
159
+ 'GIT_PUSH_FORBIDDEN',
160
+ [
161
+ '建議執行以下指令讓 git 使用 gh 的認證:',
162
+ ' gh auth setup-git',
163
+ '或者改用 SSH 權限:',
164
+ ' git remote set-url origin git@github.com:<org>/<repo>.git',
165
+ ],
166
+ `git push -u origin ${branch}`
167
+ );
168
+ }
151
169
  throw new PRError(
152
170
  '推送失敗',
153
171
  'GIT_PUSH_FAILED',