Skip to content

Commit

Permalink
add custom_metadata to the example
Browse files Browse the repository at this point in the history
shows how to add custom metadat when adding new bundle, and shows how to use the custom metadata in the client
  • Loading branch information
dennisvang committed Feb 22, 2024
1 parent a6804e6 commit a284a4a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion repo_add_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
repo = Repository.from_config()

# Add new app bundle to repository (automatically reads myapp.__version__)
repo.add_bundle(new_bundle_dir=bundle_dir)
repo.add_bundle(
new_bundle_dir=bundle_dir,
# [optional] custom metadata can be any dict (default is None)
custom_metadata={'changes': ['new feature x added', 'bug y fixed']},
)
repo.publish_changes(private_key_dirs=[KEYS_DIR])

print('Done.')
12 changes: 7 additions & 5 deletions src/myapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ def update(pre: str, skip_confirmation: bool = False):
# Perform update
new_update = client.check_for_updates(pre=pre)
if new_update:
# At this point, the version info from `new_update` could be used to
# present a custom confirmation dialog, asking the user if they wish
# to proceed with the download (and installation). However, to keep
# the example minimal, we simply rely on the built-in command-line
# confirmation in download_and_apply_update().
# [optional] use custom metadata, if available
if new_update.custom:
# for example, show list of changes (see repo_add_bundle.py for definition)
print('changes in this update:')
for item in new_update.custom.get('changes', []):
print(f'\t- {item}')
# apply the update
client.download_and_apply_update(
skip_confirmation=skip_confirmation,
progress_hook=progress_hook,
Expand Down

0 comments on commit a284a4a

Please sign in to comment.