Skip to content

Commit

Permalink
Merge pull request #261 from GEOS-ESM/hotfix/mathomp4/fix-ignore-for-old
Browse files Browse the repository at this point in the history
Fixes for older mepo clones in re ignore_submodules
  • Loading branch information
mathomp4 authored Aug 25, 2023
2 parents fc44ba9 + 8f54159 commit a675833
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

## [1.51.1] - 2023-08-25

### Fixed

- Fixes to allow mepo to work on older mepo clones that don't have ignore_submodules in their state

## [1.51.0] - 2023-08-25

### Added
Expand Down
17 changes: 15 additions & 2 deletions mepo.d/command/diff/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
from shutil import get_terminal_size

def run(args):
print('Diffing...'); sys.stdout.flush()
foundDiff = False

allcomps = MepoState.read_state()
comps2diff = _get_comps_to_diff(args.comp_name, allcomps)

for comp in comps2diff:
result = check_component_diff(comp, args)
if result:
if not foundDiff:
print('Diffing...'); sys.stdout.flush()
foundDiff = True
print_diff(comp, args, result)

if not foundDiff:
print('No diffs found')

def _get_comps_to_diff(specified_comps, allcomps):
comps_to_diff = allcomps
if specified_comps:
Expand All @@ -29,7 +35,14 @@ def _get_comps_to_diff(specified_comps, allcomps):

def check_component_diff(comp, args):
git = GitRepository(comp.remote, comp.local)
return git.run_diff(args, comp.ignore_submodules)

# Older mepo clones will not have ignore_submodules in comp, so
# we need to handle this gracefully
try:
_ignore_submodules = comp.ignore_submodules
except AttributeError:
_ignore_submodules = None
return git.run_diff(args, _ignore_submodules)

def print_diff(comp, args, output):
columns, lines = get_terminal_size(fallback=(80,20))
Expand Down
9 changes: 8 additions & 1 deletion mepo.d/command/status/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ def run(args):
def check_component_status(comp, ignore_permissions):
git = GitRepository(comp.remote, comp.local)

# Older mepo clones will not have ignore_submodules in comp, so
# we need to handle this gracefully
try:
_ignore_submodules = comp.ignore_submodules
except AttributeError:
_ignore_submodules = None

# version_to_string can strip off 'origin/' for display purposes
# so we save the "internal" name for comparison
internal_state_branch_name = git.get_version()[0]
Expand All @@ -32,7 +39,7 @@ def check_component_status(comp, ignore_permissions):
# This command is to try and work with git tag oddities
curr_ver = sanitize_version_string(orig_ver,curr_ver,git)

return (curr_ver, internal_state_branch_name, git.check_status(ignore_permissions,comp.ignore_submodules))
return (curr_ver, internal_state_branch_name, git.check_status(ignore_permissions,_ignore_submodules))

def print_status(allcomps, result, nocolor=False, hashes=False):
orig_width = len(max([comp.name for comp in allcomps], key=len))
Expand Down
9 changes: 8 additions & 1 deletion mepo.d/state/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ def __init__(self):
self.ignore_submodules = None

def __repr__(self):
# Older mepo clones will not have ignore_submodules in comp, so
# we need to handle this gracefully
try:
_ignore_submodules = self.ignore_submodules
except AttributeError:
_ignore_submodules = None

return '{} - local: {}, remote: {}, version: {}, sparse: {}, develop: {}, recurse_submodules: {}, fixture: {}, ignore_submodules: {}'.format(
self.name, self.local, self.remote, self.version, self.sparse, self.develop, self.recurse_submodules, self.fixture, self.ignore_submodules)
self.name, self.local, self.remote, self.version, self.sparse, self.develop, self.recurse_submodules, self.fixture, _ignore_submodules)

def __set_original_version(self, comp_details):
if self.fixture:
Expand Down

0 comments on commit a675833

Please sign in to comment.