Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
current-ticket.md
current-note.md
.ticket-config.override.yaml
.DS_Store
.claude
tmp
Expand Down
6 changes: 6 additions & 0 deletions DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ The main script uses a case statement to route commands:
- Creates `tickets/` directory
- Updates `.gitignore`

#### `load_config_with_override()`
- Loads main configuration from `.ticket-config.yaml` or `.ticket-config.yml`
- Optionally applies overrides from `.ticket-config.override.yaml`
- Override values take precedence over main config values
- Supports adding new configuration fields via override

#### `create_ticket()`
- Validates slug format
- Generates timestamp-based filename
Expand Down
24 changes: 24 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,30 @@ default_content: |
{{Additional notes or requirements.}}
```

### 設定オーバーライド

メイン設定ファイルを変更せずにローカル設定をカスタマイズするには、`.ticket-config.override.yaml` を作成します:

```yaml
# メイン設定から特定の値をオーバーライド
tickets_dir: "my-custom-tickets"
auto_push: false
start_success_message: |
この環境用のカスタムメッセージ
```

**仕組み:**
- オーバーライドファイルはオプション - なくても正常に動作
- `.ticket-config.override.yaml` の値がメイン設定より優先される
- 既存の値をオーバーライドしたり、新しい設定フィールドを追加可能
- 自動的に `.gitignore` に追加される(リポジトリにコミットされない)
- ローカル開発、異なるチームメンバー、環境固有の設定に便利

**一般的な使用例:**
- **開発者固有の設定**: 異なるブランチプレフィックス、ディレクトリ、メッセージ
- **環境固有の設定**: テスト環境での自動プッシュを無効化
- **チームのカスタマイズ**: 異なるチームメンバーがパーソナライズされたワークフローを持てる

## 高度な機能

### スマートなブランチ処理
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,30 @@ default_content: |
{{Additional notes or requirements.}}
```

### Configuration Override

For local customization without modifying the main configuration file, create `.ticket-config.override.yaml`:

```yaml
# Override specific values from main config
tickets_dir: "my-custom-tickets"
auto_push: false
start_success_message: |
Custom message for this environment
```

**How it works:**
- Override file is optional - system works normally without it
- Values in `.ticket-config.override.yaml` take precedence over main config
- Can override existing values or add new configuration fields
- Automatically added to `.gitignore` (not committed to repository)
- Useful for local development, different team members, or environment-specific settings

**Common use cases:**
- **Developer-specific settings**: Different branch prefixes, directories, or messages
- **Environment-specific config**: Disable auto-push for testing environments
- **Team customization**: Different team members can have personalized workflows

## Advanced Features

### Smart Branch Handling
Expand Down
59 changes: 59 additions & 0 deletions lib/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,63 @@ get_config_file() {
# Return default for new installations
echo ".ticket-config.yaml"
fi
}

# Load configuration with override support
# This function loads the main config first, then applies any overrides from .ticket-config.override.yaml
load_config_with_override() {
local main_config_file="$1"
local override_config_file=".ticket-config.override.yaml"

# Parse main config file
if ! yaml_parse "$main_config_file"; then
echo "Error: Cannot parse configuration file: $main_config_file" >&2
return 1
fi

# If override file exists, parse it and apply overrides
if [[ -f "$override_config_file" ]]; then
# Create backup of current parsed config
local temp_keys=("${_YAML_KEYS[@]}")
local temp_values=("${_YAML_VALUES[@]}")

# Parse override file
if yaml_parse "$override_config_file"; then
# Get override keys and values
local override_keys=("${_YAML_KEYS[@]}")
local override_values=("${_YAML_VALUES[@]}")

# Restore main config
_YAML_KEYS=("${temp_keys[@]}")
_YAML_VALUES=("${temp_values[@]}")

# Apply overrides
local i j
for i in "${!override_keys[@]}"; do
local override_key="${override_keys[$i]}"
local override_value="${override_values[$i]}"

# Find if key exists in main config and replace it
local key_found=false
for j in "${!_YAML_KEYS[@]}"; do
if [[ "${_YAML_KEYS[$j]}" == "$override_key" ]]; then
_YAML_VALUES[$j]="$override_value"
key_found=true
break
fi
done

# If key doesn't exist in main config, add it
if [[ "$key_found" == false ]]; then
_YAML_KEYS+=("$override_key")
_YAML_VALUES+=("$override_value")
fi
done
else
echo "Error: Cannot parse override configuration file: $override_config_file" >&2
return 1
fi
fi

return 0
}
18 changes: 18 additions & 0 deletions spec.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,24 @@ default_content: |
Additional notes or requirements.
```

### 設定オーバーライド

ローカルカスタマイズ用のオプションファイル `.ticket-config.override.yaml`:

```yaml
# メイン設定から任意の値をオーバーライド
tickets_dir: "custom-tickets"
auto_push: false
start_success_message: "カスタムワークフローメッセージ"
```

**動作:**
- オーバーライドファイルは完全にオプション
- オーバーライドファイルの値がメイン設定より優先される
- 新しい設定フィールドを追加可能
- メイン設定の読み込み後に処理される
- initコマンドにより自動的に `.gitignore` に追加される

---

## 🧭 コマンド一覧
Expand Down
18 changes: 18 additions & 0 deletions spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,24 @@ default_content: |
Additional notes or requirements.
```

### Configuration Override

Optional `.ticket-config.override.yaml` file for local customization:

```yaml
# Override any values from main config
tickets_dir: "custom-tickets"
auto_push: false
start_success_message: "Custom workflow message"
```

**Behavior:**
- Override file is completely optional
- Values in override file take precedence over main config
- Can add new configuration fields
- Processed after main config is loaded
- Automatically added to `.gitignore` by init command

---

## 🧭 Command List
Expand Down
23 changes: 15 additions & 8 deletions src/ticket.sh
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ EOF
fi

# Parse config to get tickets_dir
if ! yaml_parse "$CONFIG_FILE"; then
if ! load_config_with_override "$CONFIG_FILE"; then
echo "Warning: Could not parse config file, using defaults" >&2
local tickets_dir="$DEFAULT_TICKETS_DIR"
else
Expand Down Expand Up @@ -449,7 +449,8 @@ EOF
if [[ ! -f .gitignore ]]; then
echo "$CURRENT_TICKET_LINK" > .gitignore
echo "$CURRENT_NOTE_LINK" >> .gitignore
echo "Created .gitignore with: $CURRENT_TICKET_LINK and $CURRENT_NOTE_LINK"
echo ".ticket-config.override.yaml" >> .gitignore
echo "Created .gitignore with: $CURRENT_TICKET_LINK, $CURRENT_NOTE_LINK, and .ticket-config.override.yaml"
else
if ! grep -q "^${CURRENT_TICKET_LINK}$" .gitignore; then
echo "$CURRENT_TICKET_LINK" >> .gitignore
Expand All @@ -463,6 +464,12 @@ EOF
else
echo ".gitignore already contains: $CURRENT_NOTE_LINK"
fi
if ! grep -q "^\.ticket-config\.override\.yaml$" .gitignore; then
echo ".ticket-config.override.yaml" >> .gitignore
echo "Added to .gitignore: .ticket-config.override.yaml"
else
echo ".gitignore already contains: .ticket-config.override.yaml"
fi
fi

echo ""
Expand Down Expand Up @@ -565,7 +572,7 @@ cmd_new() {
validate_slug "$slug" || return 1

# Load configuration
if ! yaml_parse "$CONFIG_FILE"; then
if ! load_config_with_override "$CONFIG_FILE"; then
echo "Error: Cannot parse configuration file: $CONFIG_FILE" >&2
echo "Configuration file may be corrupted or unreadable" >&2
return 1
Expand Down Expand Up @@ -724,7 +731,7 @@ EOF
check_config || return 1

# Load configuration
if ! yaml_parse "$CONFIG_FILE"; then
if ! load_config_with_override "$CONFIG_FILE"; then
echo "Error: Cannot parse configuration file: $CONFIG_FILE" >&2
echo "Configuration file may be corrupted or unreadable" >&2
return 1
Expand Down Expand Up @@ -848,7 +855,7 @@ cmd_start() {
check_config || return 1

# Load configuration
if ! yaml_parse "$CONFIG_FILE"; then
if ! load_config_with_override "$CONFIG_FILE"; then
echo "Error: Cannot parse configuration file: $CONFIG_FILE" >&2
echo "Configuration file may be corrupted or unreadable" >&2
return 1
Expand Down Expand Up @@ -1068,7 +1075,7 @@ cmd_restore() {
check_config || return 1

# Load configuration
if ! yaml_parse "$CONFIG_FILE"; then
if ! load_config_with_override "$CONFIG_FILE"; then
echo "Error: Cannot parse configuration file: $CONFIG_FILE" >&2
echo "Configuration file may be corrupted or unreadable" >&2
return 1
Expand Down Expand Up @@ -1163,7 +1170,7 @@ cmd_check() {
check_config || return 1

# Load configuration
if ! yaml_parse "$CONFIG_FILE"; then
if ! load_config_with_override "$CONFIG_FILE"; then
echo "Error: Cannot parse configuration file: $CONFIG_FILE" >&2
echo "Configuration file may be corrupted or unreadable" >&2
return 1
Expand Down Expand Up @@ -1385,7 +1392,7 @@ EOF
fi

# Load configuration
if ! yaml_parse "$CONFIG_FILE"; then
if ! load_config_with_override "$CONFIG_FILE"; then
echo "Error: Cannot parse configuration file: $CONFIG_FILE" >&2
echo "Configuration file may be corrupted or unreadable" >&2
return 1
Expand Down
Loading