Skip to content

Commit aee4dfa

Browse files
keithwillcodedevin-ai-integration[bot]
authored andcommitted
fix(ci): improve conflict resolver prompt to prevent bad merge commits (calcom#26699)
- Remove explicit git commands from the prompt to avoid Devin reproducing changes - Add validation step before pushing to detect if merge commit incorrectly includes changes from target branch - Add guidance to use git's merge functionality properly instead of manually copying content - Add rule to never reproduce or recreate changes from the target branch Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 2cfa1b1 commit aee4dfa

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

.github/workflows/devin-conflict-resolver.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ jobs:
226226
IMPORTANT: This PR is from a fork. The contributor has enabled "Allow edits from maintainers".
227227
- Clone the FORK repository: ${pr.head_repo_owner}/${pr.head_repo_name}
228228
- The branch to work on is: ${pr.head_ref}
229-
- Add the upstream remote: git remote add upstream https://github.com/${owner}/${repo}.git
230-
- Fetch upstream and merge: git fetch upstream && git merge upstream/${pr.base_ref}` : `
229+
- Add the upstream remote for ${owner}/${repo}
230+
- Fetch and merge the upstream ${pr.base_ref} branch using standard git merge` : `
231231
- Clone the repository: ${owner}/${repo}
232232
- Check out the PR branch: ${pr.head_ref}
233-
- Merge the base branch: git merge origin/${pr.base_ref}`;
233+
- Merge the base branch (${pr.base_ref}) using standard git merge`;
234234
235235
const prompt = `You are resolving merge conflicts on PR #${pr.number} in repository ${owner}/${repo}.
236236
@@ -251,16 +251,24 @@ jobs:
251251
- If unsure about a conflict, prefer keeping both changes where possible
252252
2. Test that the code still works after resolving conflicts (run lint/type checks).
253253
3. Commit the merge resolution with a clear commit message.
254-
4. Push the resolved changes to the PR branch.
255-
5. After successfully pushing the resolved changes, remove the \`devin-conflict-resolution\` label from the PR using the GitHub API.
254+
4. CRITICAL VALIDATION BEFORE PUSHING: You MUST validate your merge commit before pushing:
255+
- Run: git diff --stat HEAD^1...HEAD (shows changes relative to PR branch parent)
256+
- Run: git diff --stat HEAD^2...HEAD (shows changes relative to base branch parent)
257+
- The changes relative to the base branch parent (HEAD^2) should be SIMILAR to the original PR changes, NOT include all the new commits from ${pr.base_ref}
258+
- If your merge commit shows hundreds of files changed or includes changes that were already in ${pr.base_ref}, STOP IMMEDIATELY
259+
- A proper merge commit only contains conflict resolutions, not reproduced changes from the target branch
260+
- If validation fails: DO NOT PUSH. Log the error, explain what went wrong, and abort the task.
261+
5. Push the resolved changes to the PR branch only after validation passes.
262+
6. After successfully pushing the resolved changes, remove the \`devin-conflict-resolution\` label from the PR using the GitHub API.
256263
257264
Rules and Guidelines:
258265
1. Be careful when resolving conflicts - understand the context of both changes.
259266
2. Follow the existing code style and conventions in the repository.
260267
3. Run lint and type checks before pushing to ensure the code is valid.
261268
4. If a conflict seems too complex or risky to resolve automatically, explain the situation in a PR comment instead.
262269
5. Never ask for user confirmation. Never wait for user messages.
263-
6. CRITICAL: If this is a fork PR and you encounter ANY error when pushing (permission denied, authentication failure, etc.), you MUST fail the task immediately. Do NOT attempt to push to a new branch in the main ${owner}/${repo} repository as a workaround. Simply report the error and stop.`;
270+
6. CRITICAL: If this is a fork PR and you encounter ANY error when pushing (permission denied, authentication failure, etc.), you MUST fail the task immediately. Do NOT attempt to push to a new branch in the main ${owner}/${repo} repository as a workaround. Simply report the error and stop.
271+
7. CRITICAL: Never reproduce or recreate changes from the target branch. Your merge commit should ONLY contain conflict resolutions. If you find yourself manually copying file contents from ${pr.base_ref} or creating changes that mirror what's already in ${pr.base_ref}, you are doing it wrong. Use git's merge functionality properly - it handles bringing in changes automatically.`;
264272
265273
try {
266274
const response = await fetch('https://api.devin.ai/v1/sessions', {

0 commit comments

Comments
 (0)