Skip to content

Commit 128a0c3

Browse files
committed
Adding a first claude slash command for syncing downstream with upstream
Signed-off-by: Matthias Wessendorf <[email protected]>
1 parent f675703 commit 128a0c3

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
description: Sync downstream repo with upstream main, preserving downstream-specific files
3+
---
4+
5+
You are helping sync a downstream repository with upstream changes while preserving downstream-specific configuration files.
6+
7+
# Workflow Overview
8+
9+
1. **Pre-flight checks**: Verify clean working directory, check remotes exist
10+
2. **Fetch and merge**: Create sync branch from upstream/main, merge with `-s ours` strategy
11+
3. **Restore downstream files**: Cherry-pick specific downstream files from downstream/main
12+
4. **Update dependencies**: Run `go mod tidy && go mod vendor`
13+
5. **Commit**: Single commit with message "sync: merge upstream main with downstream config"
14+
6. **Summary**: Show what changed and next steps
15+
16+
# Downstream Files to Preserve
17+
18+
Read the list of files to preserve from `.downstream-preserve` if it exists, otherwise use this default list:
19+
- .ci-operator.yaml
20+
- .snyk
21+
- .tekton/
22+
- Dockerfile.ci
23+
- Dockerfile.ocp
24+
- Makefile-ocp.mk
25+
- OWNERS
26+
- mcp_config.toml
27+
- renovate.json
28+
29+
# Implementation Steps
30+
31+
## Step 1: Pre-flight Checks
32+
- Check if working directory is clean (`git status --porcelain`)
33+
- If not clean, warn user and ask if they want to continue
34+
- Verify `upstream` and `downstream` remotes exist
35+
- If missing, show error and list available remotes
36+
- Check if `sync-downstream` branch already exists
37+
- If it exists, ask user if they want to delete and recreate
38+
39+
## Step 2: Execute Sync
40+
Run these git commands:
41+
```bash
42+
git fetch downstream
43+
git fetch upstream
44+
git checkout -b sync-downstream upstream/main
45+
git merge -s ours --no-commit downstream/main
46+
```
47+
48+
## Step 3: Restore Downstream Files
49+
For each file/folder in the preserve list:
50+
```bash
51+
git checkout downstream/main -- <file>
52+
```
53+
54+
## Step 4: Update Dependencies
55+
```bash
56+
go mod tidy
57+
go mod vendor
58+
git add vendor/
59+
```
60+
61+
## Step 5: Commit
62+
```bash
63+
git commit -am "sync: merge upstream main with downstream config"
64+
```
65+
66+
## Step 6: Summary and Next Steps
67+
Show:
68+
- Commit SHA and message
69+
- Summary of changes (`git diff --stat downstream/main..HEAD`)
70+
- Suggested next steps:
71+
- Run tests
72+
- Push branch: `git push origin sync-downstream`
73+
- Create PR: `gh pr create --base downstream/main`
74+
75+
# Error Handling
76+
77+
- If any step fails, stop and show the error
78+
- Preserve the working state for manual intervention
79+
- Suggest rollback command: `git checkout <previous-branch> && git branch -D sync-downstream`
80+
81+
# Safety Features
82+
83+
- Show diff summary before committing
84+
- Ask for confirmation before proceeding with commit
85+
- Provide dry-run output at each step
86+
87+
Execute this workflow now. Be cautious and ask for confirmation at critical steps.

.downstream-preserve

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Downstream files/folders to preserve during upstream sync
2+
# One entry per line, supports directories with trailing /
3+
.ci-operator.yaml
4+
.snyk
5+
.tekton/
6+
Dockerfile.ci
7+
Dockerfile.ocp
8+
Makefile-ocp.mk
9+
OWNERS
10+
mcp_config.toml
11+
renovate.json

0 commit comments

Comments
 (0)