Files
ccpm-claude-code-pm/ccpm/ccpm.config
Ran Aroussi 3c8e0e7f67 Fix: Resolve bash command truncation and syntax errors (#958)
* fix: resolve bash command truncation and syntax errors

- Convert long one-liner bash commands to multiline format to prevent truncation
- Fix awk syntax errors in epic-sync.md (replace literal \n with proper newlines)
- Add missing directory separators in file path patterns
- Replace chained && operators with proper if-then blocks
- Break down complex pipe chains into step-by-step operations

Key changes:
* ccpm/scripts/pm/*.sh: Convert complex dependency parsing from one-liners to readable multiline blocks
* ccpm/ccpm.config: Break down repository URL processing into clear steps
* ccpm/commands/pm/epic-sync.md: Fix awk print statements for proper newline handling

Fixes command truncation errors like:
- Error: (eval):1: parse error near ')'
- awk: syntax error at source line 1
- command not found: !

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: additional bash syntax fixes in command documentation

- epic-merge.md: Convert complex nested commands to multiline format
  - Fix feature list generation with proper error handling
  - Break down epic issue number extraction
  - Add proper file existence checks
- epic-refresh.md: Fix task issue extraction with error handling
- epic-sync.md: Re-fix awk syntax for proper newline handling
- test-runner.md: Remove MUXI-specific reference

Prevents additional command truncation in:
- Complex subshell operations with cd and loops
- Chained grep operations for GitHub issue extraction
- Nested command substitution patterns

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: address CodeRabbit feedback on dependency parsing and SSH URL handling

- ccpm.config: Add support for ssh://git@github.com/ and ssh://github.com/ URL schemes
  - Ensures all GitHub URL variants are properly normalized
- All PM scripts: Fix dependency parsing to handle whitespace-only cases
  - Trim leading/trailing whitespace after bracket removal
  - Properly handle empty dependency lists like "depends_on: [ ]"
  - Normalize whitespace-only strings to empty strings
  - Prevents false positive dependency detection

Fixes issues where:
- SSH URLs starting with ssh://git@github.com/ would fail parsing
- Empty dependency arrays with whitespace were treated as non-empty
- Tasks with "depends_on: [ ]" were incorrectly blocked

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-24 22:32:39 +01:00

65 lines
2.0 KiB
Bash

#!/bin/bash
# CCPM Configuration
# This ensures all GitHub issues are created in the correct repository
# Function to detect repository from git remote with enhanced error handling
get_github_repo() {
local remote_url=$(git remote get-url origin 2>/dev/null)
if [ -z "$remote_url" ]; then
echo "Error: No git remote found" >&2
return 1
fi
# Handle HTTPS, SSH, and SCP-style URLs
local repo="$remote_url"
# Remove various GitHub URL prefixes
repo=$(echo "$repo" | sed -E 's#^https://github\.com/##')
repo=$(echo "$repo" | sed -E 's#^git@github\.com:##')
repo=$(echo "$repo" | sed -E 's#^ssh://git@github\.com/##')
repo=$(echo "$repo" | sed -E 's#^ssh://github\.com/##')
# Remove .git suffix if present
repo=$(echo "$repo" | sed 's#\.git$##')
# Validate format
if [[ ! "$repo" =~ ^[^/]+/[^/]+$ ]]; then
echo "Error: Invalid repository format: $repo" >&2
return 1
fi
echo "$repo"
}
# Allow environment override
if [ -n "$CCPM_GITHUB_REPO" ]; then
GITHUB_REPO="$CCPM_GITHUB_REPO"
else
GITHUB_REPO=$(get_github_repo) || exit 1
fi
# Extract owner and repo name
GITHUB_OWNER=$(echo $GITHUB_REPO | cut -d/ -f1)
GITHUB_REPO_NAME=$(echo $GITHUB_REPO | cut -d/ -f2)
# Export for gh CLI
export GH_REPO="$GITHUB_REPO"
# Validate repository exists (optional - can be disabled for performance)
if [ "${CCPM_SKIP_REPO_VALIDATION:-false}" != "true" ]; then
if ! gh repo view "$GITHUB_REPO" >/dev/null 2>&1; then
echo "Warning: Repository $GITHUB_REPO not accessible. Please ensure:" >&2
echo " 1. Repository exists on GitHub" >&2
echo " 2. You have write access" >&2
echo " 3. You're authenticated with gh CLI (run: gh auth login)" >&2
fi
fi
# Wrapper function with error handling and logging
gh_issue_create() {
echo "Creating issue in: $GITHUB_REPO" >&2
gh issue create --repo "$GITHUB_REPO" "$@"
}
# Export functions for use in other scripts
export -f get_github_repo
export -f gh_issue_create