ai-git-tools 1.0.1 → 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
|
@@ -253,8 +253,14 @@ export async function commitAllCommand(options) {
|
|
|
253
253
|
|
|
254
254
|
// 顯示最近的 commits
|
|
255
255
|
console.log(chalk.cyan('\n📋 最近的 commits:'));
|
|
256
|
-
|
|
257
|
-
|
|
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();
|
package/src/commands/commit.js
CHANGED
|
@@ -104,8 +104,14 @@ ${truncatedDiff}`;
|
|
|
104
104
|
|
|
105
105
|
// 顯示最新的 commit
|
|
106
106
|
console.log(chalk.cyan('\n📋 最新 commit:'));
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
16
|
+
const result = execSync(command, {
|
|
17
17
|
encoding: 'utf-8',
|
|
18
18
|
stdio: options.silent ? 'pipe' : 'inherit',
|
|
19
19
|
...options,
|
|
20
|
-
})
|
|
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
|
-
|
|
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
|
/**
|