Skip to content

Commit

Permalink
Merge pull request #1742 from ErikDanielsson/fix-undefined-behaviour
Browse files Browse the repository at this point in the history
Fix undefined behaviour in `update.py`
  • Loading branch information
ErikDanielsson committed Aug 5, 2022
2 parents fe991c7 + 1eebfa0 commit ccad6e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
- Add links in `README.md` for `info` and `patch` commands ([#1722](https://github.com/nf-core/tools/issues/1722)])
- Fix misc. issues with `--branch` and `--base-path` ([#1726](https://github.com/nf-core/tools/issues/1726))
- Add `branch` field to module entries in `modules.json` to record what branch a module was installed from ([#1728](https://github.com/nf-core/tools/issues/1728))
- Fix unbound variable issues and minor refactoring [#1742](https://github.com/nf-core/tools/pull/1742/)

## [v2.4.1 - Cobolt Koala Patch](https://github.com/nf-core/tools/releases/tag/2.4) - [2022-05-16]

Expand Down
27 changes: 11 additions & 16 deletions nf_core/modules/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ def __init__(
self.modules_json = ModulesJson(self.dir)
self.branch = branch

class DiffEnum(enum.Enum):
"""Enumeration to keeping track of file diffs.
Used for the --save-diff and --preview options
"""

UNCHANGED = enum.auto()
CHANGED = enum.auto()
CREATED = enum.auto()
REMOVED = enum.auto()

def _parameter_checks(self):
"""Checks the compatibilty of the supplied parameters.
Expand Down Expand Up @@ -431,18 +420,24 @@ def get_all_modules_info(self, branch=None):

# Get the git urls from the modules.json
modules_info = (
(self.modules_json.get_git_url(repo_name), branch, self.modules_json.get_base_path(repo_name), mods_shas)
(
repo_name,
self.modules_json.get_git_url(repo_name),
branch,
self.modules_json.get_base_path(repo_name),
mods_shas,
)
for (repo_name, branch), mods_shas in repos_and_branches.items()
)

# Create ModulesRepo objects
repo_objs_mods = []
for repo_url, branch, base_path, mods_shas in modules_info:
for repo_name, repo_url, branch, base_path, mods_shas in modules_info:
try:
modules_repo = ModulesRepo(remote_url=repo_url, branch=branch, base_path=base_path)
except LookupError as e:
log.warning(e)
log.info(f"Skipping modules in '{modules_repo.fullname}'")
log.info(f"Skipping modules in '{repo_name}'")
else:
repo_objs_mods.append((modules_repo, mods_shas))

Expand All @@ -453,13 +448,13 @@ def get_all_modules_info(self, branch=None):
# don't try to update those that don't
i = 0
while i < len(modules_info):
repo, module, _ = modules_info[i]
repo, module, sha = modules_info[i]
if not repo.module_exists(module):
log.warning(f"Module '{module}' does not exist in '{repo.fullname}'. Skipping...")
modules_info.pop(i)
elif sha is not None and not repo.sha_exists_on_branch(sha):
log.warning(
f"Git sha '{sha}' does not exists on the '{branch}' of '{repo.fullname}'. Skipping module '{mod}'"
f"Git sha '{sha}' does not exists on the '{repo.branch}' of '{repo.fullname}'. Skipping module '{module}'"
)
modules_info.pop(i)
else:
Expand Down

0 comments on commit ccad6e6

Please sign in to comment.