Skip to content

Commit

Permalink
Merge branch 'main' into update-tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
erinecon authored Jan 20, 2025
2 parents 4d19b75 + f00cbd7 commit 9a85ea9
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 406 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: fix-byte-order-marker
- id: mixed-line-ending
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.9.1"
rev: "v0.9.2"
hooks:
# Run the linter
- id: ruff
Expand Down
46 changes: 25 additions & 21 deletions charmcraft/application/commands/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1630,45 +1630,49 @@ def run(self, parsed_args: argparse.Namespace) -> None:

# get tips from the Store
store = Store(env.get_store_config(), needs_auth=False)
to_query = []
for lib in local_libs_data:
if lib.lib_id is None:
item = {
"charm_name": lib.charm_name,
"lib_name": lib.lib_name,
"api": lib.api,
}
else:
item = {"lib_id": lib.lib_id, "api": lib.api}
to_query.append(item)
libs_tips = store.get_libraries_tips(to_query)
try:
libs_tips = self._services.store.get_libraries_metadata(
[
project.CharmLib(
lib=f"{lib.charm_name}.{lib.lib_name}", version=str(lib.api)
)
for lib in local_libs_data
]
)
except errors.LibraryError:
raise errors.LibraryError(
message=f"Library {parsed_args.library} not found in Charmhub.",
logpath_report=False,
)

# check if something needs to be done
analysis = []
for lib_data in local_libs_data:
emit.debug(f"Verifying local lib {lib_data}")
# fix any missing lib id using the Store info
if lib_data.lib_id is None:
for tip in libs_tips.values():
for tip in libs_tips:
if (
lib_data.charm_name == tip.charm_name
and lib_data.lib_name == tip.lib_name
):
lib_data = dataclasses.replace(lib_data, lib_id=tip.lib_id)
break

tip = libs_tips.get((lib_data.lib_id, lib_data.api))
for tip in libs_tips:
if tip.lib_id == lib_data.lib_id and tip.api == lib_data.api:
break
else:
raise errors.LibraryError(
message=f"Library {parsed_args.library} not found in Charmhub.",
logpath_report=False,
)
emit.debug(f"Store tip: {tip}")
error_message = None
if tip is None:
error_message = f"Library {lib_data.full_name} not found in Charmhub."
elif tip.patch > lib_data.patch:
# the store has a higher version than local
pass
elif tip.patch < lib_data.patch:
if tip.patch < lib_data.patch:
# the store has a lower version numbers than local
error_message = f"Library {lib_data.full_name} has local changes, cannot be updated."
else:
elif tip.patch == lib_data.patch:
# same versions locally and in the store
if tip.content_hash == lib_data.content_hash:
error_message = (
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cffi==1.17.1
chardet==5.2.0
charset-normalizer==3.4.1
coverage==7.6.10
craft-application==4.8.1
craft-application==4.8.2
craft-archives==2.0.2
craft-cli==2.13.0
craft-grammar==2.0.1
Expand Down Expand Up @@ -59,7 +59,7 @@ protobuf==5.29.3
pycparser==2.22
pydantic==2.9.2
pydantic-core==2.23.4
pyfakefs==5.7.3
pyfakefs==5.7.4
pygit2==1.14.1
pylint==3.3.3
pymacaroons==0.13.0
Expand Down
Loading

0 comments on commit 9a85ea9

Please sign in to comment.