Repository: VirtusLab/git-machete
Pull request #1233 (2024-04-23 16:47:00)

Set --no-edit-merge flag automatically when using -y in traverse
When using `git machete traverse -y`, the behavior is to disable interactive rebase. However, if some branches have the `update=merge` annotation, they will show a merge commit edit window because the corresponding option `--no-edit-merge` is not set automatically. This PR changes that behavior.

codecov-commenter: ## [Codecov](https://app.codecov.io/gh/VirtusLab/git-machete/pull/1233?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 98.47%. Comparing base [(`dbd9bf8`)](https://app.codecov.io/gh/VirtusLab/git-machete/commit/dbd9bf8ed237ba22ce8d089f898161c743d3c7af?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab) to head [(`bf4cacb`)](https://app.codecov.io/gh/VirtusLab/git-machete/pull/1233?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab).


<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff            @@
##           develop    #1233   +/-   ##
========================================
  Coverage    98.47%   98.47%           
========================================
  Files           14       14           
  Lines         3679     3679           
  Branches       804      804           
========================================
  Hits          3623     3623           
  Misses          37       37           
  Partials        19       19           
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/VirtusLab/git-machete/pull/1233?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab).

PawelLipski: Makes sense! could you add a test that would've captured the unintended behavior?
PawelLipski: Oh crap, brownout of Intel mac resources 😅 

Patch:
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index b7578b6..9c32da0 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -2,6 +2,8 @@
 
 ## New in git-machete 3.25.3
 
+- fixed: `-y` option in `git machete traverse` automatically sets `--no-edit-merge` flag, to retain behavior when the `update=merge` qualifier is set (contributed by @gjulianm)
+
 ## New in git-machete 3.25.2
 
 - fixed: Homebrew deploys
diff --git a/docs/man/git-machete.1 b/docs/man/git-machete.1
index 9745949..d7f2e96 100644
--- a/docs/man/git-machete.1
+++ b/docs/man/git-machete.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
 ..
-.TH "GIT-MACHETE" "1" "Apr 21, 2024" "" "git-machete"
+.TH "GIT-MACHETE" "1" "Apr 24, 2024" "" "git-machete"
 .SH NAME
 git-machete \- git-machete 3.25.3
 .sp
diff --git a/git_machete/cli.py b/git_machete/cli.py
index db6373e..7de7057 100644
--- a/git_machete/cli.py
+++ b/git_machete/cli.py
@@ -510,7 +510,8 @@ def update_cli_options_using_parsed_args(
         elif opt == "yes":
             cli_opts.opt_yes = True
 
-    if cli_opts.opt_n and cli_opts.opt_merge:
+    if cli_opts.opt_n or cli_opts.opt_yes:
+        # Set no-edit-merge as the default, as some branches might have a merge strategy even without --merge set
         cli_opts.opt_no_edit_merge = True
     if not cli_opts.opt_merge:
         if cli_opts.opt_yes or cli_opts.opt_n:


Test patch:
diff --git a/tests/test_traverse.py b/tests/test_traverse.py
index 5b22583..99f3df4 100644
--- a/tests/test_traverse.py
+++ b/tests/test_traverse.py
@@ -790,6 +790,43 @@ class TestTraverse(BaseTest):
             """,
         )
 
+    def test_traverse_with_merge_annotation_and_yes_option(self) -> None:
+        (
+            self.repo_sandbox.remove_remote()
+            .new_branch("develop")
+            .commit()
+            .new_branch("mars")
+            .commit()
+            .new_branch("snickers")
+            .commit()
+            .check_out("mars")
+            .commit()
+            .check_out("develop")
+            .commit()
+        )
+
+        body: str = """
+            develop
+                mars update=merge
+                    snickers
+            """
+        rewrite_branch_layout_file(body)
+
+        with overridden_environment(GIT_EDITOR='false'):
+            # --yes should imply --no-edit-merge, if it doesn't then the command will fail due to a non-zero exit code from the editor
+            launch_command("traverse", "--start-from=root", "--yes"),
+
+        assert_success(
+            ["status"],
+            """
+            develop
+            |
+            o-mars  update=merge
+              |
+              o-snickers *
+            """,
+        )
+
     def test_traverse_qualifiers_no_push(self) -> None:
         self.setup_standard_tree()