From d3a7d518ec81eca16e8950e2f10716e08622426d Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Fri, 3 Jan 2025 09:08:16 -0600 Subject: [PATCH 1/7] Fixed a couple of bugs 1. shutil is required if --registry is passed 2. The function checkout_all_repos has the arg branch passed to it, not args, so use that instead --- src/mepo/command/clone.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mepo/command/clone.py b/src/mepo/command/clone.py index afb08b2..599692e 100644 --- a/src/mepo/command/clone.py +++ b/src/mepo/command/clone.py @@ -1,4 +1,5 @@ import os +import shutil import pathlib from urllib.parse import urlparse from types import SimpleNamespace @@ -119,7 +120,7 @@ def checkout_all_repos(allcomps, branch): if branch is None: raise RuntimeError("`allrepos` option must be used with a branch/tag.") for comp in allcomps: - branch_y = colors.YELLOW + args.branch + colors.RESET + branch_y = colors.YELLOW + branch + colors.RESET print(f"Checking out {branch_y} in {comp.name}") git = GitRepository(comp.remote, comp.local) - git.checkout(args.branch) + git.checkout(branch) From 96855213a4e17a45bbc72f2fd6586dd68a6a6036 Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Fri, 3 Jan 2025 11:25:39 -0600 Subject: [PATCH 2/7] Added a test for mepo clone --allrepos --- tests/test_mepo_clone.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test_mepo_clone.py b/tests/test_mepo_clone.py index 65bcd0f..c1f7af4 100644 --- a/tests/test_mepo_clone.py +++ b/tests/test_mepo_clone.py @@ -89,3 +89,33 @@ def test_mepo_clone_url_branch_directory(): status_output = get_mepo_status() assert status_output == saved_output shutil.rmtree(DIRECTORY) + + +def test_mepo_clone_url_branch_allrepos(): + if os.path.isdir(FIXTURE_NAME): + shutil.rmtree(FIXTURE_NAME) + args = SimpleNamespace( + style="prefix", + registry=None, + url=FIXTURE_URL, + branch="mepo-testing-do-not-delete", + directory=None, + partial="blobless", + allrepos=True, + ) + mepo_clone.run(args) + saved_output = """Checking status... +GEOSfvdycore | (b) mepo-testing-do-not-delete +env | (b) mepo-testing-do-not-delete +cmake | (b) mepo-testing-do-not-delete +ecbuild | (b) mepo-testing-do-not-delete +GMAO_Shared | (b) mepo-testing-do-not-delete +GEOS_Util | (b) mepo-testing-do-not-delete +FMS | (b) mepo-testing-do-not-delete +FVdycoreCubed_GridComp | (b) mepo-testing-do-not-delete +fvdycore | (b) mepo-testing-do-not-delete +""" + with contextlib_chdir(FIXTURE_NAME): + status_output = get_mepo_status() + assert status_output == saved_output + shutil.rmtree(FIXTURE_NAME) From 75f4b457d65a255c7311a6dd7c7bbdbfa086932c Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Fri, 3 Jan 2025 13:10:08 -0600 Subject: [PATCH 3/7] Added test for mepo clone --registry --- tests/input/external-components.yaml | 52 ++++++++++++++++++++++++++++ tests/test_mepo_clone.py | 33 +++++++++++++++++- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 tests/input/external-components.yaml diff --git a/tests/input/external-components.yaml b/tests/input/external-components.yaml new file mode 100644 index 0000000..e296d30 --- /dev/null +++ b/tests/input/external-components.yaml @@ -0,0 +1,52 @@ +GEOSfvdycore: + fixture: true + develop: main + +env: + local: ./@env + remote: https://github.com/GEOS-ESM/ESMA_env.git + tag: v4.29.1 + develop: main + +cmake: + local: ./@cmake + remote: https://github.com/GEOS-ESM/ESMA_cmake.git + tag: v3.55.0 + develop: develop + +ecbuild: + local: ./@cmake/@ecbuild + remote: https://github.com/GEOS-ESM/ecbuild.git + tag: geos/v1.4.0 + +GMAO_Shared: + local: ./src/Shared/@GMAO_Shared + remote: https://github.com/GEOS-ESM/GMAO_Shared.git + branch: mepo-testing-do-not-delete + sparse: ./config/GMAO_Shared.sparse + develop: main + +GEOS_Util: + local: ./src/Shared/@GMAO_Shared/@GEOS_Util + remote: https://github.com/GEOS-ESM/GEOS_Util.git + tag: v2.1.3 + develop: main + +FMS: + local: ./src/Shared/@FMS + remote: https://github.com/GEOS-ESM/FMS.git + tag: geos/2019.01.02+noaff.10 + develop: geos/release/2019.01 + +FVdycoreCubed_GridComp: + local: ./src/Components/@FVdycoreCubed_GridComp + remote: https://github.com/GEOS-ESM/FVdycoreCubed_GridComp.git + branch: develop + develop: develop + +fvdycore: + local: ./src/Components/@FVdycoreCubed_GridComp/@fvdycore + remote: https://github.com/GEOS-ESM/GFDL_atmos_cubed_sphere.git + branch: geos/develop + develop: geos/develop + diff --git a/tests/test_mepo_clone.py b/tests/test_mepo_clone.py index c1f7af4..66a4b7c 100644 --- a/tests/test_mepo_clone.py +++ b/tests/test_mepo_clone.py @@ -15,7 +15,7 @@ FIXTURE_NAME = "GEOSfvdycore-mepo-testing" FIXTURE_URL = f"https://github.com/pchakraborty/{FIXTURE_NAME}.git" - +TEST_DIR = os.path.dirname(os.path.realpath(__file__)) def get_mepo_status(): args = SimpleNamespace( @@ -119,3 +119,34 @@ def test_mepo_clone_url_branch_allrepos(): status_output = get_mepo_status() assert status_output == saved_output shutil.rmtree(FIXTURE_NAME) + + +def test_mepo_clone_url_external_registry(): + if os.path.isdir(FIXTURE_NAME): + shutil.rmtree(FIXTURE_NAME) + args = SimpleNamespace( + style="prefix", + registry=os.path.join(TEST_DIR, "input/external-components.yaml"), + url=FIXTURE_URL, + branch="mepo-testing-do-not-delete", + directory=None, + partial="blobless", + allrepos=False, + ) + mepo_clone.run(args) + saved_output = """Checking status... +GEOSfvdycore | (b) mepo-testing-do-not-delete + | external-components.yaml: \x1b[31muntracked file\x1b[0m +env | (t) v4.29.1 (DH) +cmake | (t) v3.55.0 (DH) +ecbuild | (t) geos/v1.4.0 (DH) +GMAO_Shared | (b) mepo-testing-do-not-delete +GEOS_Util | (t) v2.1.3 (DH) +FMS | (t) geos/2019.01.02+noaff.10 (DH) +FVdycoreCubed_GridComp | (b) develop +fvdycore | (b) geos/develop +""" + with contextlib_chdir(FIXTURE_NAME): + status_output = get_mepo_status() + assert status_output == saved_output + # shutil.rmtree(FIXTURE_NAME) From 18656a32abb7803ebee2657f83e83e77f21659ce Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Fri, 3 Jan 2025 13:46:42 -0600 Subject: [PATCH 4/7] Added Changelong entry, fixed test, made formatter happy --- CHANGELOG.md | 12 ++++++++++++ tests/output/output_branch_list.txt | 1 + tests/test_mepo_clone.py | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b03f3f0..27f865e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +## [2.2.1] - 2025-01-03 + +### Fixed + +- Fixed bugs in the lesser use options of `mepo clone`, `allrepos` and `registry` + + +### Added + +- Added tests for `mepo clone --allrepos` and `mepo clone --registry` + + ## [2.2.0] - 2024-12-24 diff --git a/tests/output/output_branch_list.txt b/tests/output/output_branch_list.txt index 13438e5..0fb8098 100644 --- a/tests/output/output_branch_list.txt +++ b/tests/output/output_branch_list.txt @@ -8,4 +8,5 @@ ecbuild | * (HEAD detached at geos/v1.3.0) | remotes/origin/feature/netcdf4-cmake | remotes/origin/geos/main | remotes/origin/master + | remotes/origin/mepo-testing-do-not-delete | remotes/origin/release/stable diff --git a/tests/test_mepo_clone.py b/tests/test_mepo_clone.py index 66a4b7c..cffcc10 100644 --- a/tests/test_mepo_clone.py +++ b/tests/test_mepo_clone.py @@ -17,6 +17,7 @@ FIXTURE_URL = f"https://github.com/pchakraborty/{FIXTURE_NAME}.git" TEST_DIR = os.path.dirname(os.path.realpath(__file__)) + def get_mepo_status(): args = SimpleNamespace( ignore_permissions=False, @@ -149,4 +150,4 @@ def test_mepo_clone_url_external_registry(): with contextlib_chdir(FIXTURE_NAME): status_output = get_mepo_status() assert status_output == saved_output - # shutil.rmtree(FIXTURE_NAME) + shutil.rmtree(FIXTURE_NAME) From cadd6c8a4e85b1728b14239b54f09e5c3f79e661 Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Fri, 3 Jan 2025 13:52:30 -0600 Subject: [PATCH 5/7] Bumped version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 82d3d5e..f4847a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mepo" -version = "2.2.0" +version = "2.2.1" description = "A tool for managing (m)ultiple r(epo)s" authors = [{name="GMAO SI Team", email="siteam@gmao.gsfc.nasa.gov"}] dependencies = [ From f828c63f4b70920702189cae1b0f5cebe604cc9b Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Fri, 3 Jan 2025 13:53:29 -0600 Subject: [PATCH 6/7] Fixed typo in Changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27f865e..a1c2a00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Fixed bugs in the lesser use options of `mepo clone`, `allrepos` and `registry` +- Fixed bugs in the lesser used options of `mepo clone`, `allrepos` and `registry` ### Added From 0bbd5c85bf44eca1ac660a5653daa235633e700f Mon Sep 17 00:00:00 2001 From: Purnendu Chakraborty Date: Fri, 3 Jan 2025 13:56:12 -0600 Subject: [PATCH 7/7] Fixed test for checking version --- tests/test_mepo_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mepo_commands.py b/tests/test_mepo_commands.py index 5627b27..bbe73b5 100644 --- a/tests/test_mepo_commands.py +++ b/tests/test_mepo_commands.py @@ -337,7 +337,7 @@ def test_reset(self): self.__class__.__mepo_clone() def test_mepo_version(self): - self.assertEqual(get_mepo_version(), "2.2.0") + self.assertEqual(get_mepo_version(), "2.2.1") def tearDown(self): pass