ai-git-tool 1.4.0 → 1.5.0
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/README.md +13 -0
- package/dist/commands/checkout.js +27 -1
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -167,6 +167,19 @@ fix/api-error-handling
|
|
|
167
167
|
docs/readme-update
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
+
### ブランチ切り替え + 最新化
|
|
171
|
+
|
|
172
|
+
既存ブランチ名を引数に渡すと、ブランチへ移動してから `git pull` で最新化します。
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
ai-git checkout main
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
実行内容:
|
|
179
|
+
|
|
180
|
+
- `git checkout <branch>`
|
|
181
|
+
- `git pull`
|
|
182
|
+
|
|
170
183
|
### 言語設定
|
|
171
184
|
|
|
172
185
|
デフォルト言語は日本語です。
|
|
@@ -8,7 +8,33 @@ const branch_js_1 = require("../services/branch.js");
|
|
|
8
8
|
/**
|
|
9
9
|
* checkout コマンドの実行
|
|
10
10
|
*/
|
|
11
|
-
async function runCheckoutCommand() {
|
|
11
|
+
async function runCheckoutCommand(targetBranch) {
|
|
12
|
+
if (targetBranch) {
|
|
13
|
+
const checkoutResult = (0, child_process_1.spawnSync)("git", ["checkout", targetBranch], {
|
|
14
|
+
stdio: "inherit",
|
|
15
|
+
});
|
|
16
|
+
if (checkoutResult.status !== 0) {
|
|
17
|
+
(0, errors_js_1.showFriendlyError)(`ブランチへの移動に失敗しました: ${targetBranch}`, "git checkout コマンドが失敗しました", [
|
|
18
|
+
`ブランチが存在するか確認: git branch -a | grep ${targetBranch}`,
|
|
19
|
+
"現在の変更を確認: git status",
|
|
20
|
+
"未コミット変更がある場合は commit または stash を実施",
|
|
21
|
+
], [`手動で移動: git checkout ${targetBranch}`]);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
console.log(`✅ ブランチに移動しました: ${targetBranch}`);
|
|
25
|
+
console.log(`🔄 最新を取得中... (${targetBranch})`);
|
|
26
|
+
const pullResult = (0, child_process_1.spawnSync)("git", ["pull"], { stdio: "inherit" });
|
|
27
|
+
if (pullResult.status !== 0) {
|
|
28
|
+
(0, errors_js_1.showFriendlyError)(`pull に失敗しました: ${targetBranch}`, "git pull コマンドが失敗しました(競合や upstream 未設定の可能性があります)", [
|
|
29
|
+
"upstream を確認: git branch -vv",
|
|
30
|
+
"必要なら upstream を設定: git branch --set-upstream-to=origin/<branch>",
|
|
31
|
+
"競合がある場合は解消してから再実行",
|
|
32
|
+
], [`手動で実行: git pull origin ${targetBranch}`]);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
console.log(`✅ 最新状態に更新しました: ${targetBranch}`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
12
38
|
const suggested = await (0, ai_js_1.suggestBranchName)();
|
|
13
39
|
const branchName = (0, branch_js_1.ensureAvailableBranchName)(suggested);
|
|
14
40
|
const result = (0, child_process_1.spawnSync)("git", ["checkout", "-b", branchName], {
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ Commands:
|
|
|
34
34
|
commit Generate commit message from staged changes
|
|
35
35
|
push Commit with AI message and push to remote (git add . + commit + push)
|
|
36
36
|
pr Generate PR description and create pull request
|
|
37
|
-
checkout
|
|
37
|
+
checkout [branch] Create branch from changes, or switch+pull existing branch
|
|
38
38
|
|
|
39
39
|
Commit Options:
|
|
40
40
|
--lang <ja|en> Set language for this run
|
|
@@ -64,7 +64,7 @@ if (!subcommand ||
|
|
|
64
64
|
console.error(" ai-git commit - AI でコミットメッセージを生成してコミット");
|
|
65
65
|
console.error(" ai-git push - コミット後、リモートにプッシュ");
|
|
66
66
|
console.error(" ai-git pr - PR の説明を生成して Pull Request を作成");
|
|
67
|
-
console.error(" ai-git checkout -
|
|
67
|
+
console.error(" ai-git checkout - 引数なし: 新規ブランチ作成 / 引数あり: ブランチ移動して pull");
|
|
68
68
|
console.error("");
|
|
69
69
|
console.error("💡 詳しい使い方:");
|
|
70
70
|
console.error(" ai-git --help");
|
|
@@ -78,7 +78,7 @@ const language = (0, config_js_1.resolveLanguage)(langArg);
|
|
|
78
78
|
// ── メイン ───────────────────────────────────────────────
|
|
79
79
|
async function main() {
|
|
80
80
|
if (subcommand === "checkout") {
|
|
81
|
-
await (0, checkout_js_1.runCheckoutCommand)();
|
|
81
|
+
await (0, checkout_js_1.runCheckoutCommand)(subcommandArgs[0]);
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
if (subcommand === "pr") {
|