From: Simon Glass <simon.glass@canonical.com> Add per-commit delta-checking and build-validation to the cherry-pick and review agents: - Check commit deltas after each cherry-pick to catch problems early - Run buildman after each commit instead of only at the end - Add recovery strategies for commits with large deltas - Include delta checking in rebase operations - Improve error handling and reporting Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- tools/pickman/agent.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/tools/pickman/agent.py b/tools/pickman/agent.py index d2a9ba562f8..89014df0120 100644 --- a/tools/pickman/agent.py +++ b/tools/pickman/agent.py @@ -91,19 +91,35 @@ Steps to follow: Cherry-pick one commit at a time to handle each appropriately. IMPORTANT: Always include merge commits even if they result in empty commits. The merge commit message is important for tracking history. -4. If there are conflicts: +4. AFTER EACH SUCCESSFUL CHERRY-PICK: + a) Check commit delta: 'git show --stat <cherry-picked-hash>' and 'git show --stat <original-hash>' + Compare the changed files and line counts. If they differ significantly (>20% lines changed + or different files modified), this indicates a problem with the cherry-pick. + b) Build test: Run 'buildman -L --board sandbox -w -o /tmp/pickman' to verify the build passes + c) If delta is too large: + - Reset the commit: 'git reset --hard HEAD~1' + - Try to manually apply just the changes from the original commit: + 'git show <original-hash> | git apply --3way' + - If that succeeds, create a new commit with the original message + - If fails, try to apply the patch manually. + - If manual apply fails, create an empty commit to preserve the commit sequence: + 'git commit --allow-empty -m "<original-subject> [FAILED]"' + - Continue to the next commit + d) If build fails and you cannot resolve it, report the issue and abort +5. If there are conflicts: - Show the conflicting files - Try to resolve simple conflicts automatically - For complex conflicts, describe what needs manual resolution and abort - When fix-ups are needed, amend the commit to add a one-line note at the end of the commit message describing the changes made -5. After ALL cherry-picks complete, verify with +6. After ALL cherry-picks complete, verify with 'git log --oneline -n {len(commits) + 2}' Ensure all {len(commits)} commits are present. -6. Run 'buildman -L --board sandbox -w -o /tmp/pickman' to verify the build -7. Report the final status including: +7. Run final build: 'buildman -L --board sandbox -w -o /tmp/pickman' to verify everything still works together +8. Report the final status including: - Build result (ok or list of warnings/errors) - Any fix-ups that were made + - Any commits with concerning deltas The cherry-pick branch will be left ready for pushing. Do NOT merge it back to any other branch. @@ -243,6 +259,10 @@ Rebase instructions: - The MR is behind the target branch and needs rebasing - Use: git rebase --keep-empty {remote}/{target} - This preserves empty merge commits which are important for tracking +- AFTER EACH REBASED COMMIT: Check delta and build + a) Compare commit delta before/after rebase using 'git show --stat' + b) Run 'buildman -L --board sandbox -w -o /tmp/pickman' to verify build passes + c) If delta is significantly different or build fails, report and abort - If there are conflicts, try to resolve them automatically - For complex conflicts that cannot be resolved, describe them and abort ''' @@ -297,7 +317,7 @@ Steps to follow: 2. {step2} 3. {step3} {comment_steps} -4. Run 'buildman -L --board sandbox -w -o /tmp/pickman' to verify the build +4. Run 'buildman -L --board sandbox -w -o /tmp/pickman' to verify the build passes 5. Create a local branch with suffix '-v2' (or increment: -v3, -v4, etc.) 6. Force push to the ORIGINAL remote branch to update the MR: ./tools/pickman/pickman push-branch {branch_name} -r {remote} -f -- 2.43.0