ai-git-tools 1.0.0 → 1.0.2

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": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "AI-powered Git automation tools for commit messages and PR generation",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -12,7 +12,8 @@
12
12
  "test": "echo \"Error: no test specified\" && exit 1",
13
13
  "prepare": "chmod +x bin/cli.js",
14
14
  "lint": "eslint src/**/*.js",
15
- "format": "prettier --write \"src/**/*.js\" \"bin/**/*.js\""
15
+ "format": "prettier --write \"src/**/*.js\" \"bin/**/*.js\"",
16
+ "prepublishOnly": "npm run lint"
16
17
  },
17
18
  "keywords": [
18
19
  "git",
@@ -39,7 +40,7 @@
39
40
  "CHANGELOG.md"
40
41
  ],
41
42
  "dependencies": {
42
- "@github/copilot-sdk": "^1.0.0",
43
+ "@github/copilot-sdk": "0.1.20",
43
44
  "commander": "^12.0.0",
44
45
  "chalk": "^5.3.0",
45
46
  "ora": "^8.0.1",
@@ -253,8 +253,14 @@ export async function commitAllCommand(options) {
253
253
 
254
254
  // 顯示最近的 commits
255
255
  console.log(chalk.cyan('\n📋 最近的 commits:'));
256
- const recentCommits = GitOperations.getRecentCommits(successCount);
257
- console.log(recentCommits);
256
+ try {
257
+ const recentCommits = GitOperations.getRecentCommits(successCount);
258
+ if (recentCommits) {
259
+ console.log(recentCommits);
260
+ }
261
+ } catch (error) {
262
+ // 忽略顯示 commit 的錯誤
263
+ }
258
264
 
259
265
  // Reset 任何剩餘的 staged 檔案
260
266
  GitOperations.resetStaged();
@@ -104,8 +104,14 @@ ${truncatedDiff}`;
104
104
 
105
105
  // 顯示最新的 commit
106
106
  console.log(chalk.cyan('\n📋 最新 commit:'));
107
- const recentCommits = GitOperations.getRecentCommits(1);
108
- console.log(recentCommits);
107
+ try {
108
+ const recentCommits = GitOperations.getRecentCommits(1);
109
+ if (recentCommits) {
110
+ console.log(recentCommits);
111
+ }
112
+ } catch (error) {
113
+ // 忽略顯示 commit 的錯誤
114
+ }
109
115
 
110
116
  } catch (error) {
111
117
  logger.failSpinner('操作失敗');
@@ -13,11 +13,12 @@ export class GitOperations {
13
13
  */
14
14
  static exec(command, options = {}) {
15
15
  try {
16
- return execSync(command, {
16
+ const result = execSync(command, {
17
17
  encoding: 'utf-8',
18
18
  stdio: options.silent ? 'pipe' : 'inherit',
19
19
  ...options,
20
- }).toString();
20
+ });
21
+ return result ? result.toString().trim() : '';
21
22
  } catch (error) {
22
23
  if (options.throwOnError !== false) {
23
24
  throw error;
@@ -202,7 +203,12 @@ export class GitOperations {
202
203
  * 獲取最近的 commits
203
204
  */
204
205
  static getRecentCommits(count = 5) {
205
- return GitOperations.exec(`git log -${count} --oneline`, { silent: true });
206
+ try {
207
+ const result = GitOperations.exec(`git log -${count} --oneline`, { silent: true });
208
+ return result || '(沒有 commit 記錄)';
209
+ } catch (error) {
210
+ return '(無法獲取 commit 記錄)';
211
+ }
206
212
  }
207
213
 
208
214
  /**