Repository: VirtusLab/git-machete
Pull request #1439 (2025-05-19 15:48:49)

Fix `git machete git{hub,lab} update-{pr,mr}-descriptions --related` not updating the current PR in default intro style

codecov-commenter: ## [Codecov](https://app.codecov.io/gh/VirtusLab/git-machete/pull/1439?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab) Report
Attention: Patch coverage is `71.42857%` with `2 lines` in your changes missing coverage. Please review.
> Project coverage is 98.49%. Comparing base [(`124ff3a`)](https://app.codecov.io/gh/VirtusLab/git-machete/commit/124ff3a91d71b188b2ca26accacd2fc8863c21e2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab) to head [(`270691c`)](https://app.codecov.io/gh/VirtusLab/git-machete/commit/270691c868840918fe0de7afa8b82f8c8d8f6f5e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab).

| [Files with missing lines](https://app.codecov.io/gh/VirtusLab/git-machete/pull/1439?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab) | Patch % | Lines |
|---|---|---|
| [git\_machete/utils.py](https://app.codecov.io/gh/VirtusLab/git-machete/pull/1439?src=pr&el=tree&filepath=git_machete%2Futils.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab#diff-Z2l0X21hY2hldGUvdXRpbHMucHk=) | 50.00% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/VirtusLab/git-machete/pull/1439?src=pr&el=tree&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    #1439      +/-   ##
===========================================
- Coverage    98.56%   98.49%   -0.08%     
===========================================
  Files           26       26              
  Lines         4193     4197       +4     
  Branches       795      796       +1     
===========================================
+ Hits          4133     4134       +1     
- Misses          38       40       +2     
- Partials        22       23       +1     
```

| [Flag](https://app.codecov.io/gh/VirtusLab/git-machete/pull/1439/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab) | Coverage Δ | |
|---|---|---|
| [-f coverage.xml](https://app.codecov.io/gh/VirtusLab/git-machete/pull/1439/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab) | `98.49% <71.42%> (-0.08%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VirtusLab#carryforward-flags-in-the-pull-request-comment) to find out more.

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/VirtusLab/git-machete/pull/1439?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).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>

Patch:
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 249364f..bc1abda 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -2,6 +2,8 @@
 
 ## New in git-machete 3.35.1
 
+- fixed: `git machete git{hub,lab} update-{pr,mr}-descriptions --related` could not update the current PR/MR in default intro style
+
 ## New in git-machete 3.35.0
 
 - added: `git machete traverse --sync-github-prs`/`--sync-gitlab-mrs` suggests creating PRs/MRs for branches without one (suggested by @bradneuman and @tir38)
diff --git a/git_machete/client/with_code_hosting.py b/git_machete/client/with_code_hosting.py
index b02d4ef..9ca114c 100644
--- a/git_machete/client/with_code_hosting.py
+++ b/git_machete/client/with_code_hosting.py
@@ -762,6 +762,7 @@ class MacheteClientWithCodeHosting(MacheteClient):
             related_to = None
         applicable_prs: List[PullRequest] = self._get_applicable_pull_requests(
             all=all, by=current_user if mine else by, related_to=related_to)
+        debug("applicable PRs: " + ", ".join(pr.display_text() for pr in applicable_prs))
 
         for pr in applicable_prs:
             new_description = self._get_updated_pull_request_description(pr)
@@ -935,9 +936,10 @@ class MacheteClientWithCodeHosting(MacheteClient):
             return result
         elif related_to:
             style = self.__get_pr_description_into_style_from_config()
-            result = []
             if style in (PRDescriptionIntroStyle.FULL, PRDescriptionIntroStyle.FULL_NO_BRANCHES):
-                result += reversed(self.__get_upwards_path_including_pr(related_to))
+                result = list(reversed(self.__get_upwards_path_including_pr(related_to)))
+            else:
+                result = [related_to]
             result += [pr_ for pr_, _ in self.__get_downwards_tree_excluding_pr(related_to)]
             return result
 
diff --git a/git_machete/utils.py b/git_machete/utils.py
index 7119dee..5eb65cf 100644
--- a/git_machete/utils.py
+++ b/git_machete/utils.py
@@ -4,6 +4,7 @@ import os
 import re
 import subprocess
 import sys
+import textwrap
 import time
 from typing import (Any, Callable, Dict, Iterable, List, NamedTuple, Optional,
                     Set, Tuple, TypeVar)
@@ -113,16 +114,18 @@ def debug(msg: str) -> None:
         function_name = bold(inspect.stack()[1].function)
         args, _, _, values_original = inspect.getargvalues(inspect.stack()[1].frame)
         # Do not write over the original values!
-        # Since Python 3.13, this keeps a map of local variables that the code actually sees,
-        # so overwriting a key in values_original actually changes the local variable.
-        values = dict(values_original)
+        # Since Python 3.13, the result of `getargvalues` keeps a map of local variables
+        # that the Python runtime actually keeps on the stack,
+        # so overwriting a key in values_original changes the local variable.
+        values: Dict[str, Any] = dict(values_original)
 
         args_to_be_redacted = {'access_token', 'password', 'secret', 'token'}
         for arg, value in values.items():
             if arg in args_to_be_redacted or any(value_ in str(value) for value_ in CODE_HOSTING_TOKEN_PREFIXES):
                 values[arg] = '***'
-            if type(values[arg]) is dict:
-                values[arg] = compact_dict(values[arg])
+            elif type(value) is dict:
+                values[arg] = compact_dict(value)
+            values[arg] = textwrap.shorten(str(values[arg]), width=50, placeholder="...")
 
         args_and_values_list = [arg + '=' + str(values[arg]) for arg in excluding(args, {'self'})]
         args_and_values_str = ', '.join(args_and_values_list)


Test patch:
diff --git a/tests/test_github_update_pr_descriptions.py b/tests/test_github_update_pr_descriptions.py
index 9c2a6f9..b012fdb 100644
--- a/tests/test_github_update_pr_descriptions.py
+++ b/tests/test_github_update_pr_descriptions.py
@@ -119,6 +119,7 @@ class TestGitHubUpdatePRDescriptions(BaseTest):
             """
         )
 
+        check_out('chore/redundant_checks')
         assert_success(
             ['github', 'update-pr-descriptions', '--related'],
             """