Skip to content

Commit

Permalink
Merge pull request #259 from GEOS-ESM/develop
Browse files Browse the repository at this point in the history
GitFlow: Merge Develop into main
  • Loading branch information
mathomp4 authored Aug 25, 2023
2 parents 912a251 + 2f21c3f commit fc44ba9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

## [1.51.0] - 2023-08-25

### Added

- Added new `ignore_submodules` field in `components.yaml` to allow ignoring submodules in a repo. Currently used for `status` and
`diff` commands.

## [1.50.0] - 2023-08-17

### Added
Expand Down
2 changes: 1 addition & 1 deletion mepo.d/command/diff/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ 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)
return git.run_diff(args, comp.ignore_submodules)

def print_diff(comp, args, output):
columns, lines = get_terminal_size(fallback=(80,20))
Expand Down
4 changes: 2 additions & 2 deletions mepo.d/command/status/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def run(args):
result = pool.starmap(check_component_status, [(comp, args.ignore_permissions) for comp in allcomps])
print_status(allcomps, result, args.nocolor, args.hashes)

def check_component_status(comp, ignore):
def check_component_status(comp, ignore_permissions):
git = GitRepository(comp.remote, comp.local)

# version_to_string can strip off 'origin/' for display purposes
Expand All @@ -32,7 +32,7 @@ def check_component_status(comp, ignore):
# 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))
return (curr_ver, internal_state_branch_name, git.check_status(ignore_permissions,comp.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
8 changes: 6 additions & 2 deletions mepo.d/repository/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def show_stash(self, patch):
output = shellcmd.run(shlex.split(cmd),output=True)
return output.rstrip()

def run_diff(self, args=None):
def run_diff(self, args=None, ignore_submodules=False):
cmd = 'git -C {}'.format(self.__full_local_path)
if args.ignore_permissions:
cmd += ' -c core.fileMode=false'
Expand All @@ -135,6 +135,8 @@ def run_diff(self, args=None):
cmd += ' --staged'
if args.ignore_space_change:
cmd += ' --ignore-space-change'
if ignore_submodules:
cmd += ' --ignore-submodules=all'
output = shellcmd.run(shlex.split(cmd),output=True)
return output.rstrip()

Expand Down Expand Up @@ -199,11 +201,13 @@ def verify_branch_or_tag(self, ref_name):
ref_type = "Branch"
return status, ref_type

def check_status(self, ignore_permissions=False):
def check_status(self, ignore_permissions=False, ignore_submodules=False):
cmd = 'git -C {}'.format(self.__full_local_path)
if ignore_permissions:
cmd += ' -c core.fileMode=false'
cmd += ' status --porcelain=v2'
if ignore_submodules:
cmd += ' --ignore-submodules=all'
output = shellcmd.run(shlex.split(cmd), output=True)
if output.strip():
output_list = output.splitlines()
Expand Down
12 changes: 8 additions & 4 deletions mepo.d/state/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class MepoComponent(object):

__slots__ = ['name', 'local', 'remote', 'version', 'sparse', 'develop', 'recurse_submodules', 'fixture']
__slots__ = ['name', 'local', 'remote', 'version', 'sparse', 'develop', 'recurse_submodules', 'fixture', 'ignore_submodules']

def __init__(self):
self.name = None
Expand All @@ -22,10 +22,11 @@ def __init__(self):
self.develop = None
self.recurse_submodules = None
self.fixture = None
self.ignore_submodules = None

def __repr__(self):
return '{} - local: {}, remote: {}, version: {}, sparse: {}, develop: {}, recurse_submodules: {}, fixture: {}'.format(
self.name, self.local, self.remote, self.version, self.sparse, self.develop, self.recurse_submodules, self.fixture)
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)

def __set_original_version(self, comp_details):
if self.fixture:
Expand Down Expand Up @@ -71,7 +72,7 @@ def __set_original_version(self, comp_details):
self.version = MepoVersion(ver_name, ver_type, is_detached)

def __validate_fixture(self, comp_details):
unallowed_keys = ['remote', 'local', 'branch', 'hash', 'tag', 'sparse', 'recurse_submodules']
unallowed_keys = ['remote', 'local', 'branch', 'hash', 'tag', 'sparse', 'recurse_submodules', 'ignore_submodules']
if any([comp_details.get(key) for key in unallowed_keys]):
raise Exception("Fixtures are only allowed fixture and develop")

Expand Down Expand Up @@ -135,6 +136,7 @@ def to_component(self, comp_name, comp_details, comp_style):
self.sparse = comp_details.get('sparse', None) # sparse is optional
self.develop = comp_details.get('develop', None) # develop is optional
self.recurse_submodules = comp_details.get('recurse_submodules', None) # recurse_submodules is optional
self.ignore_submodules = comp_details.get('ignore_submodules', None) # ignore_submodules is optional
self.__set_original_version(comp_details)
return self

Expand Down Expand Up @@ -163,6 +165,8 @@ def to_dict(self, start):
details['develop'] = self.develop
if self.recurse_submodules:
details['recurse_submodules'] = self.recurse_submodules
if self.ignore_submodules:
details['ignore_submodules'] = self.ignore_submodules
return {self.name: details}

def get_current_remote_url():
Expand Down

0 comments on commit fc44ba9

Please sign in to comment.