diff --git a/.github/release/label_advice.py b/.github/release/label_advice.py index 2ca0461bee..9a1dc444cd 100644 --- a/.github/release/label_advice.py +++ b/.github/release/label_advice.py @@ -349,7 +349,7 @@ def declare(slug, n, value): def owed(slug, author): - """[{line, pr, title, why, command}] for author's merged PRs that a live line still owes (needs origin fetched).""" + """[{line, pr, title, why, command}] for author's merged PRs that a live line still owes, from local origin refs: main() fetches them first.""" login = author or _gh("api", "user", "--jq", ".login") rows = [] for branch, ref in sorted(rs._branches(".").items()): diff --git a/.github/release/test_label_advice.py b/.github/release/test_label_advice.py index a238911e25..2f07baa8a7 100644 --- a/.github/release/test_label_advice.py +++ b/.github/release/test_label_advice.py @@ -259,6 +259,30 @@ def test_backports_run_log_shows_only_under_actions(self): self.assertEqual(out.getvalue(), "") self.assertEqual("held: 26 main commit(s)" in err.getvalue(), shown, env) + def test_the_cli_fetches_origin_before_reading_it(self): + dev_git( + self.repo, "update-ref", "-d", "refs/remotes/origin/release/1.7" + ) # a stale clone + held = mock.Mock(return_value=[]) + old = os.getcwd() + os.chdir(self.repo) + try: + with ( + mock.patch.object( + la, "slug_from_origin", return_value="o/unstract-cloud" + ), + mock.patch.object(bp, "held", held), + mock.patch.object(bp, "pr_classes", return_value={}), + mock.patch.object(bp, "declared", return_value=[]), + mock.patch.object(la, "_gh", return_value=json.dumps([{"number": 11}])), + mock.patch("sys.stdout"), + ): + self.assertEqual(la.main(["--owed", "--author", "dev"]), 0) + finally: + os.chdir(old) + held.assert_called_once() + self.assertEqual(held.call_args.args[2], "release/1.7") + def test_backports_warnings_show_even_when_it_fails(self): def fail(*a, **k): print("::warning::PR listing failed, classing commit by commit: HTTP 403")