diff --git a/.github/scripts/release_notes_by_component.py b/.github/scripts/release_notes_by_component.py index c1ba38a127..ad350e62f7 100644 --- a/.github/scripts/release_notes_by_component.py +++ b/.github/scripts/release_notes_by_component.py @@ -264,6 +264,10 @@ def gh(*args, stdin=None): return subprocess.run(["gh", *args], input=stdin, capture_output=True, text=True, check=True).stdout +def pr_files(repo, num): + return gh("pr", "view", str(num), "-R", repo, "--json", "files", "--jq", ".files[].path").splitlines() + + def main(): ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) ap.add_argument("--repo", default="seaweedfs/seaweedfs") @@ -275,17 +279,16 @@ def main(): failed = [] - def pr_files(num): + def files_of(num): try: - out = gh("pr", "view", str(num), "-R", args.repo, "--json", "files", "--jq", ".files[].path") + return pr_files(args.repo, num) except subprocess.CalledProcessError as e: print("warning: files of #%d: %s" % (num, e.stderr.strip()), file=sys.stderr) failed.append(num) return [] - return out.splitlines() try: - notes = regroup(body, pr_files) + notes = regroup(body, files_of) except ValueError as e: sys.exit("release %s: %s" % (args.tag, e)) sys.stdout.write(notes) diff --git a/.github/scripts/test_release_notes_by_component.py b/.github/scripts/test_release_notes_by_component.py index ee542c6a7a..5abf30e5ba 100644 --- a/.github/scripts/test_release_notes_by_component.py +++ b/.github/scripts/test_release_notes_by_component.py @@ -1,6 +1,7 @@ import importlib.util from pathlib import Path import unittest +from unittest import mock def load(): @@ -96,6 +97,12 @@ class ClassifyTest(unittest.TestCase): files=["weed/s3api/auth.go", "test/s3/iam/test_a.py", "test/s3/iam/test_b.py"]) self.check("Cover more", "Tests and CI", files=["test/s3/iam/test_a.py"]) + def test_path_with_space(self): + with mock.patch.object(rn, "gh", return_value="test/s3/iam/policy cases.json\n"): + files = rn.pr_files("seaweedfs/seaweedfs", 1) + self.assertEqual(files, ["test/s3/iam/policy cases.json"]) + self.check("Cover more", "Tests and CI", files=files) + NOTES = """## What's Changed * filer: fail health check when absent from lock ring by @a in https://github.com/seaweedfs/seaweedfs/pull/12709