diff --git a/CHANGELOG.md b/CHANGELOG.md index b03f3f0f..a1c2a00e 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 used 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/pyproject.toml b/pyproject.toml index 82d3d5ed..f4847a1b 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 = [ diff --git a/src/mepo/command/clone.py b/src/mepo/command/clone.py index afb08b25..599692ea 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) diff --git a/tests/input/external-components.yaml b/tests/input/external-components.yaml new file mode 100644 index 00000000..e296d30d --- /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/output/output_branch_list.txt b/tests/output/output_branch_list.txt index 13438e52..0fb80988 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 65bcd0fd..cffcc102 100644 --- a/tests/test_mepo_clone.py +++ b/tests/test_mepo_clone.py @@ -15,6 +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(): @@ -89,3 +90,64 @@ 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) + + +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) diff --git a/tests/test_mepo_commands.py b/tests/test_mepo_commands.py index 5627b279..bbe73b5d 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