-
Notifications
You must be signed in to change notification settings - Fork 64
[hotfix] Extension example for clean could not import Conan API search #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
fe21b3b
3005ea6
1660eb1
4014bbb
91894c3
48c7135
729e9f7
b8f2745
ae4d974
e1ed8d7
d20946c
6374c7e
cf2df99
02907c2
7ddaca0
e877703
9d08b9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from conan.api.conan_api import ConanAPI | ||
from conan.api.model import PackagesList, ListPattern | ||
from conan.api.input import UserInput | ||
from conan.api.output import ConanOutput, Color | ||
from conan.cli.command import OnceArgument, conan_command | ||
|
@@ -27,26 +28,24 @@ def confirmation(message): | |
remote = conan_api.remotes.get(args.remote) if args.remote else None | ||
output_remote = remote or "Local cache" | ||
|
||
# Getting all the recipes | ||
recipes = conan_api.search.recipes("*/*", remote=remote) | ||
if recipes and not confirmation("Do you want to remove all the recipes revisions and their packages ones, " | ||
# Get all recipes and packages, where recipe revision is not the latest | ||
pkg_list = conan_api.list.select(ListPattern("*/*#!latest:*#*", rrev=None, prev=None), remote=remote) | ||
|
||
if pkg_list and not confirmation("Do you want to remove all the recipes revisions and their packages ones, " | ||
"except the latest package revision from the latest recipe one?"): | ||
out.writeln("Aborted") | ||
return | ||
for recipe in recipes: | ||
out.writeln(f"{str(recipe)}", fg=recipe_color) | ||
all_rrevs = conan_api.list.recipe_revisions(recipe, remote=remote) | ||
latest_rrev = all_rrevs[0] if all_rrevs else None | ||
for rrev in all_rrevs: | ||
if rrev != latest_rrev: | ||
conan_api.remove.recipe(rrev, remote=remote) | ||
out.writeln(f"Removed recipe revision: {rrev.repr_notime()} " | ||
f"and all its package revisions [{output_remote}]", fg=removed_color) | ||
else: | ||
packages = conan_api.list.packages_configurations(rrev, remote=remote) | ||
for package_ref in packages: | ||
all_prevs = conan_api.list.package_revisions(package_ref, remote=remote) | ||
latest_prev = all_prevs[0] if all_prevs else None | ||
for prev in all_prevs: | ||
if prev != latest_prev: | ||
conan_api.remove.package(prev, remote=remote) | ||
out.writeln(f"Removed package revision: {prev.repr_notime()} [{output_remote}]", fg=removed_color) | ||
|
||
# Remove all packages for old recipe revisions | ||
for recipe_ref, recipe_bundle in pkg_list.refs().items(): | ||
conan_api.remove.recipe(recipe_ref, remote=remote) | ||
out.writeln(f"Removed recipe revision: {recipe_ref.repr_notime()} " | ||
f"and all its package revisions [{output_remote}]", fg=removed_color) | ||
|
||
# Get all package revisions from the latest recipe revision, except the latest package revision | ||
pkg_list = conan_api.list.select(ListPattern("*/*#latest:*#!latest", rrev=None, prev=None), remote=remote) | ||
for recipe_ref, recipe_bundle in pkg_list.refs().items(): | ||
pkg_list = PackagesList.prefs(recipe_ref, recipe_bundle) | ||
|
||
for pkg_ref in pkg_list.keys(): | ||
# Remove all package revisions except the latest one | ||
conan_api.remove.package(pkg_ref, remote=remote) | ||
out.writeln(f"Removed package revision: {pkg_ref.repr_notime()} [{output_remote}]", fg=removed_color) |
Uh oh!
There was an error while loading. Please reload this page.