Skip to content

Commit 176cbdd

Browse files
Fixes #347. Add blobless option to components.yaml (#364)
* Fixes #347. Add blobless option to components.yaml * Fix up test * Update src/mepo/command/clone.py Co-authored-by: pchakraborty <pchakraborty@users.noreply.github.com> --------- Co-authored-by: pchakraborty <pchakraborty@users.noreply.github.com>
1 parent e08ead3 commit 176cbdd

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
### Added
1313

1414
- Added ahead/behind info to `mepo status`
15+
- Added `blobless:` option to `components.yaml` to force blobless cloning for a repo
1516

1617
### Changed
1718

src/mepo/cmdline/parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def __init__(self, option_strings, dest, const=True, help=None):
2121
super().__init__(option_strings, dest, const, help=help)
2222

2323
def __call__(self, parser, namespace, values, option_string=None):
24-
import os, sys
24+
import os
25+
import sys
2526
import mepo
2627

2728
print(os.path.dirname(mepo.__file__))

src/mepo/command/clone.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def get_registry(arg_registry):
9292
return registry
9393

9494

95-
def clone_components(allcomps, partial):
95+
def clone_components(allcomps, arg_partial):
9696
max_namelen = max([len(comp.name) for comp in allcomps])
9797
for comp in allcomps:
9898
if comp.fixture:
@@ -101,7 +101,14 @@ def clone_components(allcomps, partial):
101101
# According to Git, treeless clones do not interact well with
102102
# submodules. So if any comp has the recurse option set to True,
103103
# we do a non-partial clone
104-
partial = None if partial == "treeless" and recurse_submodules else partial
104+
partial = arg_partial
105+
if arg_partial == "treeless" and recurse_submodules:
106+
partial = None
107+
108+
# The components.yaml can specify blobless as an option so that wins out
109+
if comp.blobless:
110+
partial = "blobless"
111+
105112
version = comp.version.name
106113
version = version.replace("origin/", "")
107114
git = GitRepository(comp.remote, comp.local)

src/mepo/component.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import shlex
32

43
from dataclasses import dataclass
54
from urllib.parse import urljoin
@@ -25,6 +24,7 @@ class MepoComponent(object):
2524
"recurse_submodules",
2625
"fixture",
2726
"ignore_submodules",
27+
"blobless",
2828
]
2929

3030
def __init__(
@@ -38,6 +38,7 @@ def __init__(
3838
recurse_submodules=None,
3939
fixture=None,
4040
ignore_submodules=None,
41+
blobless=None,
4142
):
4243
self.name = name
4344
self.local = local
@@ -48,6 +49,7 @@ def __init__(
4849
self.recurse_submodules = recurse_submodules
4950
self.fixture = fixture
5051
self.ignore_submodules = ignore_submodules
52+
self.blobless = blobless
5153

5254
def __repr__(self):
5355
# Older mepo clones will not have ignore_submodules in comp, so
@@ -66,6 +68,7 @@ def __repr__(self):
6668
f" develop: {self.develop}\n"
6769
f" recurse_submodules: {self.recurse_submodules}\n"
6870
f" fixture: {self.fixture}\n"
71+
f" blobless: {self.blobless}\n"
6972
f" ignore_submodules: {_ignore_submodules}"
7073
)
7174

@@ -131,6 +134,7 @@ def registry_to_component(self, comp_name, comp_details, comp_style):
131134
self.develop = comp_details.get("develop", None)
132135
self.recurse_submodules = comp_details.get("recurse_submodules", None)
133136
self.ignore_submodules = comp_details.get("ignore_submodules", None)
137+
self.blobless = comp_details.get("blobless", None)
134138
# version
135139
self.__set_original_version(comp_details)
136140

@@ -165,6 +169,8 @@ def to_registry_format(self):
165169
details["recurse_submodules"] = self.recurse_submodules
166170
if self.ignore_submodules:
167171
details["ignore_submodules"] = self.ignore_submodules
172+
if self.blobless:
173+
details["blobless"] = self.blobless
168174
return {self.name: details}
169175

170176
def deserialize(self, d):

tests/output/output_branch_list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ecbuild | * (HEAD detached at geos/v1.3.0)
33
| remotes/origin/HEAD -> origin/geos/develop
44
| remotes/origin/develop
55
| remotes/origin/feature/FindMKL-portability-improvement
6+
| remotes/origin/geos-develop-before-2025May13-merge
67
| remotes/origin/geos/develop
78
| remotes/origin/geos/main
89
| remotes/origin/master

tests/test_component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def get_fvdycore_serialized():
4343
"recurse_submodules": None,
4444
"fixture": False,
4545
"ignore_submodules": None,
46+
"blobless": None,
4647
}
4748

4849

@@ -60,7 +61,6 @@ def test_stylize_local_path():
6061

6162
def test_MepoComponent():
6263
registry = get_registry()
63-
complist = list()
6464
for name, comp in registry.items():
6565
if name == "fvdycore":
6666
fvdycore = MepoComponent().registry_to_component(name, comp, None)

0 commit comments

Comments
 (0)