spec-runner 1.0.12 → 1.0.13

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": "spec-runner",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "フェーズ駆動で設計先行を強制。npx で .spec-runner を展開し、次のステップ .md に従って進める",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -19,7 +19,10 @@ ARGS=()
19
19
  for a in "$@"; do
20
20
  case "$a" in
21
21
  --yes|-y) YES_MODE=true ;;
22
- *) ARGS+=("$a") ;;
22
+ *)
23
+ # 空引数は無視(例: "" "task-management" "カテゴリ")
24
+ [[ -n "$a" ]] && ARGS+=("$a")
25
+ ;;
23
26
  esac
24
27
  done
25
28
 
@@ -114,14 +117,25 @@ if git rev-parse --verify "$BRANCH_NAME" >/dev/null 2>&1; then
114
117
  fi
115
118
 
116
119
  CURRENT=$(git branch --show-current 2>/dev/null || echo "")
117
- MAIN_BRANCH="main"
118
- if ! git rev-parse --verify "$MAIN_BRANCH" >/dev/null 2>&1; then
119
- MAIN_BRANCH="master"
120
- if ! git rev-parse --verify "$MAIN_BRANCH" >/dev/null 2>&1; then
121
- echo "Error: main master も存在しません。" >&2
122
- exit 1
120
+ MAIN_BRANCH=""
121
+
122
+ # 1) origin/HEAD からデフォルトブランチを取得
123
+ if git symbolic-ref -q --short refs/remotes/origin/HEAD >/dev/null 2>&1; then
124
+ MAIN_BRANCH="$(git symbolic-ref -q --short refs/remotes/origin/HEAD | sed 's#^origin/##')"
125
+ fi
126
+ # 2) main / master をフォールバック
127
+ if [[ -z "$MAIN_BRANCH" ]]; then
128
+ if git rev-parse --verify "main" >/dev/null 2>&1; then
129
+ MAIN_BRANCH="main"
130
+ elif git rev-parse --verify "master" >/dev/null 2>&1; then
131
+ MAIN_BRANCH="master"
123
132
  fi
124
133
  fi
134
+ # 3) どれも無ければ現在ブランチ(初期ブランチ名が trunk/develop 等のケース)
135
+ if [[ -z "$MAIN_BRANCH" ]]; then
136
+ MAIN_BRANCH="${CURRENT:-}"
137
+ fi
138
+ [[ -n "$MAIN_BRANCH" ]] || { echo "Error: ベースブランチを特定できません(main/master/current が見つかりません)。" >&2; exit 1; }
125
139
 
126
140
  if [[ "$YES_MODE" != true ]]; then
127
141
  echo "次の UC を開始する準備をします。"