Skip to content

Commit d3a2521

Browse files
fix(wizard): detect and update git remote from template to user repository
## Problem When users clone the blueprint template and run the wizard, git remote still points to the template repository (alirezarezvani/claude-code-github-workflow). This causes: - Permission denied when pushing (can't push to template) - Secrets set on wrong repository - Workflows run on template instead of user's project - Users unable to actually use the blueprint ## Solution Added automatic git remote detection and update in setup wizard: **1. Setup Wizard Enhancement** (setup/wizard.sh) - New function: update_git_remote() (Step 1.5) - Detects if git remote points to template repository - Prompts user for their repository owner/name - Updates git remote to user's repository - Validates the change was successful - Updates REPO_OWNER and REPO_NAME variables - Exits if user declines update (must fix manually) **2. Validation Script Enhancement** (setup/validate.sh) - New validation: validate_git_remote() (Section 0) - Checks git remote configuration before other checks - Fails validation if still pointing to template - Provides clear error message and fix instructions - Shows current vs expected remote URL **3. Documentation Updates** - QUICK_START.md: Added note about cloning to own repository - COMPLETE_SETUP.md: Added Step 1.5 "Configure Git Remote" - Both docs explain why this matters and how to fix ## Impact - ✅ Users guided to set up correctly from the start - ✅ Clear error messages if remote not updated - ✅ Validation catches this issue before other failures - ✅ Automatic fix via wizard (asks user for repo details) - ✅ Manual fix instructions provided if user declines ## Testing - Wizard prompts for repository when template remote detected - Wizard skips update when remote already correct - Validation script catches template remote - Documentation provides clear instructions Fixes critical setup issue where users couldn't actually use the blueprint. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8740420 commit d3a2521

4 files changed

Lines changed: 186 additions & 2 deletions

File tree

docs/COMPLETE_SETUP.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,36 @@ cp -r blueprint/setup/ ./setup/
176176
rm -rf blueprint
177177
```
178178

179+
#### Step 1.5: Configure Git Remote
180+
181+
**CRITICAL**: The blueprint is a template. You must use it in YOUR own repository.
182+
183+
**If you cloned the template directly**:
184+
```bash
185+
# Check current remote
186+
git remote get-url origin
187+
# If it shows: https://github.com/alirezarezvani/claude-code-github-workflow.git
188+
# You need to update it!
189+
190+
# Option A: Create new GitHub repository and update remote
191+
gh repo create my-project --public --source=. --remote=origin
192+
193+
# Option B: Manually update to existing repository
194+
git remote set-url origin https://github.com/YOUR_USERNAME/YOUR_REPO.git
195+
196+
# Verify the change
197+
git remote get-url origin
198+
# Should show YOUR repository, not the template
199+
```
200+
201+
**Why this matters**:
202+
-**Wrong**: Pushing to template repository (you don't have permission)
203+
-**Right**: Pushing to your own repository
204+
- The setup wizard will detect and help fix this automatically
205+
206+
**If you copied files to existing repository**:
207+
- No action needed - your git remote is already correct ✅
208+
179209
#### Step 2: Configure for Your Project Type
180210

181211
**For Web Projects**:

docs/QUICK_START.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Before you begin, ensure you have:
4040

4141
### Step 1: Clone and Setup
4242

43-
Copy this blueprint into your project:
43+
**Important**: This blueprint is a template. You need to use it in YOUR own repository.
4444

4545
```bash
4646
# Option A: Add to existing repository
@@ -51,11 +51,19 @@ cp -r .blueprint-temp/.claude/ .
5151
cp -r .blueprint-temp/setup/ .
5252
rm -rf .blueprint-temp
5353

54-
# Option B: Start new project with blueprint
54+
# Option B: Clone template, then create your own repository
5555
git clone https://github.com/alirezarezvani/claude-code-github-workflow.git my-project
5656
cd my-project
57+
58+
# Create your own GitHub repository
59+
gh repo create my-project --public --source=. --remote=origin
60+
61+
# Or manually update git remote
62+
git remote set-url origin https://github.com/YOUR_USERNAME/YOUR_REPO.git
5763
```
5864

65+
**Note**: The setup wizard (see below) will detect if you're still pointing to the template repository and help you update it automatically.
66+
5967
### Step 2: Configure Secrets
6068

6169
Add required secrets to your repository:

setup/validate.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,54 @@ This script validates your repository configuration.
101101
EOF
102102
}
103103

104+
# ─────────────────────────────────────────────────────────────────
105+
# 0. Git Remote Validation
106+
# ─────────────────────────────────────────────────────────────────
107+
108+
validate_git_remote() {
109+
log_section "0. Checking Git Remote Configuration"
110+
111+
# Check if in git repository
112+
if ! git rev-parse --git-dir &> /dev/null; then
113+
log_fail "Not in a git repository"
114+
return 1
115+
fi
116+
117+
# Get current remote URL
118+
local current_remote=$(git remote get-url origin 2>/dev/null || echo "")
119+
120+
if [[ -z "$current_remote" ]]; then
121+
log_fail "No git remote 'origin' configured"
122+
log_info "Configure with: git remote add origin <repo-url>"
123+
return 1
124+
fi
125+
126+
# Check if pointing to template repository
127+
local template_repo="alirezarezvani/claude-code-github-workflow"
128+
129+
if [[ "$current_remote" == *"$template_repo"* ]]; then
130+
log_fail "Git remote is still pointing to template repository!"
131+
echo ""
132+
echo -e "${RED}⚠️ CRITICAL: You are using the blueprint template repository directly!${NC}"
133+
echo ""
134+
echo " Current remote: $current_remote"
135+
echo ""
136+
echo " This will cause issues:"
137+
echo " • Cannot push changes (permission denied)"
138+
echo " • Secrets set on wrong repository"
139+
echo " • Workflows run on template, not your project"
140+
echo ""
141+
echo " To fix, update git remote to YOUR repository:"
142+
echo " git remote set-url origin https://github.com/<your-username>/<your-repo>.git"
143+
echo ""
144+
echo " Or run the setup wizard again: ./setup/wizard.sh"
145+
echo ""
146+
else
147+
log_pass "Git remote configured correctly"
148+
log_info "Remote: $current_remote"
149+
fi
150+
}
151+
104152
# ─────────────────────────────────────────────────────────────────
105153
# 1. Branch Validation
106154
# ─────────────────────────────────────────────────────────────────
@@ -618,6 +666,7 @@ main() {
618666
show_header
619667

620668
# Run all validation checks
669+
validate_git_remote
621670
validate_branches
622671
validate_secrets
623672
validate_workflows

setup/wizard.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,100 @@ check_prerequisites() {
190190
return 0
191191
}
192192

193+
# ─────────────────────────────────────────────────────────────────
194+
# Step 1.5: Repository Remote Setup
195+
# ─────────────────────────────────────────────────────────────────
196+
197+
update_git_remote() {
198+
log_step "Step 1.5: Repository Remote Setup"
199+
200+
# Get current remote URL
201+
local current_remote=$(git remote get-url origin 2>/dev/null || echo "")
202+
203+
if [[ -z "$current_remote" ]]; then
204+
log_error "No git remote 'origin' found"
205+
log_info "This should not happen if prerequisites passed"
206+
return 1
207+
fi
208+
209+
log_info "Current remote: $current_remote"
210+
211+
# Check if pointing to template repository
212+
local template_repo="alirezarezvani/claude-code-github-workflow"
213+
214+
if [[ "$current_remote" == *"$template_repo"* ]]; then
215+
log_warning "Git remote is still pointing to the template repository!"
216+
echo ""
217+
echo "⚠️ You need to update the remote URL to YOUR repository."
218+
echo ""
219+
echo "This blueprint is a template - you should be using it in YOUR"
220+
echo "own repository, not the original template repository."
221+
echo ""
222+
223+
# Prompt for user's repository
224+
echo "📋 Please provide your GitHub repository information:"
225+
echo ""
226+
227+
local user_owner=""
228+
local user_repo=""
229+
230+
while [[ -z "$user_owner" ]]; do
231+
read -p "$(echo -e "${YELLOW}?${NC} Repository owner (your username or org): ")" user_owner
232+
if [[ -z "$user_owner" ]]; then
233+
log_error "Repository owner cannot be empty"
234+
fi
235+
done
236+
237+
while [[ -z "$user_repo" ]]; do
238+
read -p "$(echo -e "${YELLOW}?${NC} Repository name: ")" user_repo
239+
if [[ -z "$user_repo" ]]; then
240+
log_error "Repository name cannot be empty"
241+
fi
242+
done
243+
244+
# Construct new remote URL (using HTTPS)
245+
local new_remote="https://github.com/$user_owner/$user_repo.git"
246+
247+
echo ""
248+
log_info "New remote URL: $new_remote"
249+
echo ""
250+
251+
if ! confirm "Update git remote to this URL?"; then
252+
log_warning "Git remote not updated."
253+
echo ""
254+
log_error "You MUST update the git remote before proceeding!"
255+
echo ""
256+
echo "To update manually, run:"
257+
echo " git remote set-url origin https://github.com/<owner>/<repo>.git"
258+
echo ""
259+
echo "Then run this wizard again."
260+
return 1
261+
fi
262+
263+
# Update remote URL
264+
if git remote set-url origin "$new_remote"; then
265+
log "Git remote updated successfully!"
266+
267+
# Verify the change
268+
local updated_remote=$(git remote get-url origin)
269+
log_info "Verified remote: $updated_remote"
270+
271+
# Update global variables
272+
REPO_OWNER="$user_owner"
273+
REPO_NAME="$user_repo"
274+
else
275+
log_error "Failed to update git remote"
276+
return 1
277+
fi
278+
else
279+
log "Git remote is already configured correctly"
280+
log_info "Remote: $current_remote"
281+
fi
282+
283+
echo ""
284+
return 0
285+
}
286+
193287
# ─────────────────────────────────────────────────────────────────
194288
# Step 2: Detect Project Type
195289
# ─────────────────────────────────────────────────────────────────
@@ -966,6 +1060,9 @@ main() {
9661060
# Step 1: Check prerequisites
9671061
check_prerequisites || exit 1
9681062

1063+
# Step 1.5: Update git remote if needed
1064+
update_git_remote || exit 1
1065+
9691066
# Step 2: Detect project type
9701067
detect_project_type
9711068

0 commit comments

Comments
 (0)