Skip to content

Commit 3a589f4

Browse files
daniel-lxsbrunobergher
authored andcommitted
fix: add GIT_EDITOR env var to merge-resolver mode for non-interactive rebase (#7819)
1 parent 98668ba commit 3a589f4

File tree

3 files changed

+75
-10
lines changed

3 files changed

+75
-10
lines changed

.roo/rules-merge-resolver/1_workflow.xml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
<tools>
3131
<tool>gh pr checkout [PR_NUMBER] --force</tool>
3232
<tool>git fetch origin main</tool>
33-
<tool>git rebase origin/main</tool>
33+
<tool>GIT_EDITOR=true git rebase origin/main</tool>
3434
</tools>
3535
<details>
3636
Force checkout the PR branch to ensure clean state
3737
Fetch the latest main branch
3838
Attempt to rebase onto main to reveal conflicts
39+
Use GIT_EDITOR=true to ensure non-interactive rebase
3940
</details>
4041
</step>
4142

@@ -108,8 +109,8 @@
108109
</command>
109110

110111
<command name="rebase_main">
111-
<syntax>git rebase origin/main</syntax>
112-
<purpose>Rebase current branch onto main to reveal conflicts</purpose>
112+
<syntax>GIT_EDITOR=true git rebase origin/main</syntax>
113+
<purpose>Rebase current branch onto main to reveal conflicts (non-interactive)</purpose>
113114
</command>
114115

115116
<command name="get_blame_info">
@@ -133,6 +134,20 @@
133134
</command>
134135
</git_commands>
135136

137+
<command name="continue_rebase">
138+
<syntax>GIT_EDITOR=true git rebase --continue</syntax>
139+
<purpose>Continue rebase after resolving conflicts (non-interactive)</purpose>
140+
</command>
141+
</git_commands>
142+
143+
<environment_variables>
144+
<variable name="GIT_EDITOR">
145+
<value>true</value>
146+
<purpose>Set to 'true' (a no-op command) to prevent interactive prompts during rebase operations</purpose>
147+
<usage>Prefix git rebase commands with GIT_EDITOR=true to ensure non-interactive execution</usage>
148+
</variable>
149+
</environment_variables>
150+
136151
<completion_criteria>
137152
<criterion>All merge conflicts have been resolved</criterion>
138153
<criterion>Resolved files have been staged</criterion>

.roo/rules-merge-resolver/3_tool_usage.xml

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<practice>Chain git commands with && for efficiency</practice>
2727
<practice>Use --format options for structured output</practice>
2828
<practice>Capture command output for parsing</practice>
29+
<practice>Use GIT_EDITOR=true for non-interactive git rebase operations</practice>
30+
<practice>Set environment variables inline to avoid prompts during automation</practice>
2931
</best_practices>
3032

3133
<common_commands>
@@ -46,7 +48,7 @@
4648

4749
<command>
4850
<purpose>Rebase onto main to reveal conflicts</purpose>
49-
<syntax>git rebase origin/main</syntax>
51+
<syntax>GIT_EDITOR=true git rebase origin/main</syntax>
5052
</command>
5153

5254
<command>
@@ -71,7 +73,7 @@
7173

7274
<command>
7375
<purpose>Continue rebase after resolution</purpose>
74-
<syntax>git rebase --continue</syntax>
76+
<syntax>GIT_EDITOR=true git rebase --continue</syntax>
7577
</command>
7678
</common_commands>
7779
</tool>
@@ -152,7 +154,7 @@ const config = {
152154
<step>execute_command - Get PR info with gh CLI</step>
153155
<step>execute_command - Checkout PR with gh pr checkout --force</step>
154156
<step>execute_command - Fetch origin main</step>
155-
<step>execute_command - Rebase onto origin/main</step>
157+
<step>execute_command - Rebase onto origin/main with GIT_EDITOR=true</step>
156158
<step>execute_command - Check for conflicts with git status</step>
157159
</sequence>
158160
</pattern>
@@ -178,13 +180,22 @@ const config = {
178180
<pattern name="complete_rebase">
179181
<sequence>
180182
<step>execute_command - Check all conflicts resolved</step>
181-
<step>execute_command - Continue rebase with git rebase --continue</step>
183+
<step>execute_command - Continue rebase with GIT_EDITOR=true git rebase --continue</step>
182184
<step>execute_command - Verify clean status</step>
183185
</sequence>
184186
</pattern>
185187
</tool_combination_patterns>
186188

187189
<error_handling>
190+
<scenario name="interactive_prompt_blocking">
191+
<description>Git commands waiting for interactive input</description>
192+
<approach>
193+
Use GIT_EDITOR=true to bypass editor prompts
194+
Set GIT_SEQUENCE_EDITOR=true for sequence editing
195+
Consider --no-edit flag for commit operations
196+
</approach>
197+
</scenario>
198+
188199
<scenario name="no_conflicts_after_rebase">
189200
<description>Rebase completes without conflicts</description>
190201
<approach>
@@ -225,4 +236,42 @@ const config = {
225236
</approach>
226237
</scenario>
227238
</error_handling>
239+
240+
<non_interactive_operations>
241+
<overview>
242+
Ensuring git operations run without requiring user interaction is critical
243+
for automated conflict resolution. The mode uses environment variables to
244+
bypass interactive prompts.
245+
</overview>
246+
247+
<techniques>
248+
<technique name="GIT_EDITOR">
249+
<description>Set to 'true' (a no-op command) to skip editor prompts</description>
250+
<usage>GIT_EDITOR=true git rebase --continue</usage>
251+
<when>During rebase operations that would normally open an editor</when>
252+
</technique>
253+
254+
<technique name="GIT_SEQUENCE_EDITOR">
255+
<description>Skip interactive rebase todo editing</description>
256+
<usage>GIT_SEQUENCE_EDITOR=true git rebase -i HEAD~3</usage>
257+
<when>When interactive rebase is triggered but no editing needed</when>
258+
</technique>
259+
260+
<technique name="commit_flags">
261+
<description>Use flags to avoid interactive prompts</description>
262+
<examples>
263+
<example>git commit --no-edit (use existing message)</example>
264+
<example>git merge --no-edit (skip merge message editing)</example>
265+
<example>git cherry-pick --no-edit (keep original message)</example>
266+
</examples>
267+
</technique>
268+
</techniques>
269+
270+
<best_practices>
271+
<practice>Always test commands locally first to identify potential prompts</practice>
272+
<practice>Combine environment variables when multiple editors might be invoked</practice>
273+
<practice>Document why non-interactive mode is used in comments</practice>
274+
<practice>Have fallback strategies if automation fails</practice>
275+
</best_practices>
276+
</non_interactive_operations>
228277
</merge_resolver_tool_usage>

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ From github.com:user/repo
5454

5555
<tool_use><![CDATA[
5656
<execute_command>
57-
<command>git rebase origin/main</command>
57+
<command>GIT_EDITOR=true git rebase origin/main</command>
5858
</execute_command>
5959
]]></tool_use>
6060
<expected_output><![CDATA[
@@ -251,7 +251,7 @@ abc123 Fix: Add listener cleanup to prevent memory leak
251251

252252
<tool_use><![CDATA[
253253
<execute_command>
254-
<command>git rebase --continue</command>
254+
<command>GIT_EDITOR=true git rebase --continue</command>
255255
</execute_command>
256256
]]></tool_use>
257257
<expected_output><![CDATA[
@@ -309,7 +309,8 @@ Both the feature refactor and the critical bugfix have been preserved in the res
309309
<takeaway>Use git blame and commit messages to understand the history</takeaway>
310310
<takeaway>Combine non-conflicting improvements when possible</takeaway>
311311
<takeaway>Prioritize bugfixes while accommodating refactors</takeaway>
312-
<takeaway>Complete the rebase process with git rebase --continue</takeaway>
312+
<takeaway>Use GIT_EDITOR=true to ensure non-interactive rebase operations</takeaway>
313+
<takeaway>Complete the rebase process with GIT_EDITOR=true git rebase --continue</takeaway>
313314
<takeaway>Validate that both sets of changes work together</takeaway>
314315
</key_takeaways>
315316
</merge_resolver_example>

0 commit comments

Comments
 (0)