Просмотр исходного кода

fix: add GIT_EDITOR env var to merge-resolver mode for non-interactive rebase (#7819)

Daniel 3 месяцев назад
Родитель
Сommit
39030bf273

+ 18 - 3
.roo/rules-merge-resolver/1_workflow.xml

@@ -30,12 +30,13 @@
       <tools>
       <tools>
         <tool>gh pr checkout [PR_NUMBER] --force</tool>
         <tool>gh pr checkout [PR_NUMBER] --force</tool>
         <tool>git fetch origin main</tool>
         <tool>git fetch origin main</tool>
-        <tool>git rebase origin/main</tool>
+        <tool>GIT_EDITOR=true git rebase origin/main</tool>
       </tools>
       </tools>
       <details>
       <details>
         Force checkout the PR branch to ensure clean state
         Force checkout the PR branch to ensure clean state
         Fetch the latest main branch
         Fetch the latest main branch
         Attempt to rebase onto main to reveal conflicts
         Attempt to rebase onto main to reveal conflicts
+        Use GIT_EDITOR=true to ensure non-interactive rebase
       </details>
       </details>
     </step>
     </step>
 
 
@@ -108,8 +109,8 @@
     </command>
     </command>
     
     
     <command name="rebase_main">
     <command name="rebase_main">
-      <syntax>git rebase origin/main</syntax>
-      <purpose>Rebase current branch onto main to reveal conflicts</purpose>
+      <syntax>GIT_EDITOR=true git rebase origin/main</syntax>
+      <purpose>Rebase current branch onto main to reveal conflicts (non-interactive)</purpose>
     </command>
     </command>
     
     
     <command name="get_blame_info">
     <command name="get_blame_info">
@@ -133,6 +134,20 @@
     </command>
     </command>
   </git_commands>
   </git_commands>
 
 
+    <command name="continue_rebase">
+      <syntax>GIT_EDITOR=true git rebase --continue</syntax>
+      <purpose>Continue rebase after resolving conflicts (non-interactive)</purpose>
+    </command>
+  </git_commands>
+
+  <environment_variables>
+    <variable name="GIT_EDITOR">
+      <value>true</value>
+      <purpose>Set to 'true' (a no-op command) to prevent interactive prompts during rebase operations</purpose>
+      <usage>Prefix git rebase commands with GIT_EDITOR=true to ensure non-interactive execution</usage>
+    </variable>
+  </environment_variables>
+
   <completion_criteria>
   <completion_criteria>
     <criterion>All merge conflicts have been resolved</criterion>
     <criterion>All merge conflicts have been resolved</criterion>
     <criterion>Resolved files have been staged</criterion>
     <criterion>Resolved files have been staged</criterion>

+ 53 - 4
.roo/rules-merge-resolver/3_tool_usage.xml

@@ -26,6 +26,8 @@
         <practice>Chain git commands with && for efficiency</practice>
         <practice>Chain git commands with && for efficiency</practice>
         <practice>Use --format options for structured output</practice>
         <practice>Use --format options for structured output</practice>
         <practice>Capture command output for parsing</practice>
         <practice>Capture command output for parsing</practice>
+        <practice>Use GIT_EDITOR=true for non-interactive git rebase operations</practice>
+        <practice>Set environment variables inline to avoid prompts during automation</practice>
       </best_practices>
       </best_practices>
       
       
       <common_commands>
       <common_commands>
@@ -46,7 +48,7 @@
         
         
         <command>
         <command>
           <purpose>Rebase onto main to reveal conflicts</purpose>
           <purpose>Rebase onto main to reveal conflicts</purpose>
-          <syntax>git rebase origin/main</syntax>
+          <syntax>GIT_EDITOR=true git rebase origin/main</syntax>
         </command>
         </command>
         
         
         <command>
         <command>
@@ -71,7 +73,7 @@
         
         
         <command>
         <command>
           <purpose>Continue rebase after resolution</purpose>
           <purpose>Continue rebase after resolution</purpose>
-          <syntax>git rebase --continue</syntax>
+          <syntax>GIT_EDITOR=true git rebase --continue</syntax>
         </command>
         </command>
       </common_commands>
       </common_commands>
     </tool>
     </tool>
@@ -152,7 +154,7 @@ const config = {
         <step>execute_command - Get PR info with gh CLI</step>
         <step>execute_command - Get PR info with gh CLI</step>
         <step>execute_command - Checkout PR with gh pr checkout --force</step>
         <step>execute_command - Checkout PR with gh pr checkout --force</step>
         <step>execute_command - Fetch origin main</step>
         <step>execute_command - Fetch origin main</step>
-        <step>execute_command - Rebase onto origin/main</step>
+        <step>execute_command - Rebase onto origin/main with GIT_EDITOR=true</step>
         <step>execute_command - Check for conflicts with git status</step>
         <step>execute_command - Check for conflicts with git status</step>
       </sequence>
       </sequence>
     </pattern>
     </pattern>
@@ -178,13 +180,22 @@ const config = {
     <pattern name="complete_rebase">
     <pattern name="complete_rebase">
       <sequence>
       <sequence>
         <step>execute_command - Check all conflicts resolved</step>
         <step>execute_command - Check all conflicts resolved</step>
-        <step>execute_command - Continue rebase with git rebase --continue</step>
+        <step>execute_command - Continue rebase with GIT_EDITOR=true git rebase --continue</step>
         <step>execute_command - Verify clean status</step>
         <step>execute_command - Verify clean status</step>
       </sequence>
       </sequence>
     </pattern>
     </pattern>
   </tool_combination_patterns>
   </tool_combination_patterns>
 
 
   <error_handling>
   <error_handling>
+    <scenario name="interactive_prompt_blocking">
+      <description>Git commands waiting for interactive input</description>
+      <approach>
+        Use GIT_EDITOR=true to bypass editor prompts
+        Set GIT_SEQUENCE_EDITOR=true for sequence editing
+        Consider --no-edit flag for commit operations
+      </approach>
+    </scenario>
+    
     <scenario name="no_conflicts_after_rebase">
     <scenario name="no_conflicts_after_rebase">
       <description>Rebase completes without conflicts</description>
       <description>Rebase completes without conflicts</description>
       <approach>
       <approach>
@@ -225,4 +236,42 @@ const config = {
       </approach>
       </approach>
     </scenario>
     </scenario>
   </error_handling>
   </error_handling>
+
+  <non_interactive_operations>
+    <overview>
+      Ensuring git operations run without requiring user interaction is critical
+      for automated conflict resolution. The mode uses environment variables to
+      bypass interactive prompts.
+    </overview>
+    
+    <techniques>
+      <technique name="GIT_EDITOR">
+        <description>Set to 'true' (a no-op command) to skip editor prompts</description>
+        <usage>GIT_EDITOR=true git rebase --continue</usage>
+        <when>During rebase operations that would normally open an editor</when>
+      </technique>
+      
+      <technique name="GIT_SEQUENCE_EDITOR">
+        <description>Skip interactive rebase todo editing</description>
+        <usage>GIT_SEQUENCE_EDITOR=true git rebase -i HEAD~3</usage>
+        <when>When interactive rebase is triggered but no editing needed</when>
+      </technique>
+      
+      <technique name="commit_flags">
+        <description>Use flags to avoid interactive prompts</description>
+        <examples>
+          <example>git commit --no-edit (use existing message)</example>
+          <example>git merge --no-edit (skip merge message editing)</example>
+          <example>git cherry-pick --no-edit (keep original message)</example>
+        </examples>
+      </technique>
+    </techniques>
+    
+    <best_practices>
+      <practice>Always test commands locally first to identify potential prompts</practice>
+      <practice>Combine environment variables when multiple editors might be invoked</practice>
+      <practice>Document why non-interactive mode is used in comments</practice>
+      <practice>Have fallback strategies if automation fails</practice>
+    </best_practices>
+  </non_interactive_operations>
 </merge_resolver_tool_usage>
 </merge_resolver_tool_usage>

+ 4 - 3
.roo/rules-merge-resolver/4_complete_example.xml

@@ -54,7 +54,7 @@ From github.com:user/repo
       
       
       <tool_use><![CDATA[
       <tool_use><![CDATA[
 <execute_command>
 <execute_command>
-<command>git rebase origin/main</command>
+<command>GIT_EDITOR=true git rebase origin/main</command>
 </execute_command>
 </execute_command>
       ]]></tool_use>
       ]]></tool_use>
       <expected_output><![CDATA[
       <expected_output><![CDATA[
@@ -251,7 +251,7 @@ abc123 Fix: Add listener cleanup to prevent memory leak
       
       
       <tool_use><![CDATA[
       <tool_use><![CDATA[
 <execute_command>
 <execute_command>
-<command>git rebase --continue</command>
+<command>GIT_EDITOR=true git rebase --continue</command>
 </execute_command>
 </execute_command>
       ]]></tool_use>
       ]]></tool_use>
       <expected_output><![CDATA[
       <expected_output><![CDATA[
@@ -309,7 +309,8 @@ Both the feature refactor and the critical bugfix have been preserved in the res
     <takeaway>Use git blame and commit messages to understand the history</takeaway>
     <takeaway>Use git blame and commit messages to understand the history</takeaway>
     <takeaway>Combine non-conflicting improvements when possible</takeaway>
     <takeaway>Combine non-conflicting improvements when possible</takeaway>
     <takeaway>Prioritize bugfixes while accommodating refactors</takeaway>
     <takeaway>Prioritize bugfixes while accommodating refactors</takeaway>
-    <takeaway>Complete the rebase process with git rebase --continue</takeaway>
+    <takeaway>Use GIT_EDITOR=true to ensure non-interactive rebase operations</takeaway>
+    <takeaway>Complete the rebase process with GIT_EDITOR=true git rebase --continue</takeaway>
     <takeaway>Validate that both sets of changes work together</takeaway>
     <takeaway>Validate that both sets of changes work together</takeaway>
   </key_takeaways>
   </key_takeaways>
 </merge_resolver_example>
 </merge_resolver_example>