Skip to content

Commit 384093b

Browse files
add --add
1 parent e110f29 commit 384093b

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

scripts/fix_outdated.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def get_next(
143143

144144

145145
def fix_uninstallable(
146-
lockfile_name: str, toolshed_url: str, galaxy_url: Optional[str] = None
146+
lockfile_name: str, toolshed_url: str, galaxy_url: Optional[str] = None, add:bool = False
147147
) -> None:
148148
ts = toolshed.ToolShedInstance(url=toolshed_url)
149149
installed_tools: Dict[Tuple[str, str], Set[str]] = {}
@@ -202,21 +202,25 @@ def fix_uninstallable(
202202
)
203203
continue
204204
if all_versions[cur] != all_versions[nxt]:
205-
logger.warning(f"{name},{owner} {cur} {nxt} have unequal versions {all_versions[cur]} {all_versions[nxt]}")
205+
logger.warning(f"{name},{owner} {cur} {nxt} have unequal versions")
206206
continue
207207

208208
if nxt not in locked_tool["revisions"]:
209-
logger.info(f"{name},{owner} Adding {nxt} which was absent so far")
210-
to_append.append(nxt)
209+
if add:
210+
logger.info(f"{name},{owner} remove {cur} in favor of {nxt} ")
211+
logger.info(f"{name},{owner} Adding {nxt} which was absent so far")
212+
to_append.append(nxt)
213+
to_remove.append(cur)
211214
elif galaxy_url:
212215
assert (name, owner) in installed_tools
213216
if cur in installed_tools[(name, owner)]:
214217
logger.warning(
215218
f"{name},{owner} {cur} still installed on {galaxy_url}"
216219
)
217220
continue
218-
logger.info(f"{name},{owner} remove {cur} in favor of {nxt} ")
219-
to_remove.append(cur)
221+
else:
222+
logger.info(f"{name},{owner} remove {cur} in favor of {nxt} ")
223+
to_remove.append(cur)
220224

221225
for r in to_remove:
222226
locked_tool["revisions"].remove(r)
@@ -237,7 +241,10 @@ def fix_uninstallable(
237241
help="Toolshed to test against",
238242
)
239243
parser.add_argument(
240-
"--galaxy_url", default=None, required=False, help="Galaxy instance to check"
244+
"--galaxy_url", default=None, required=False, help="Galaxy instance to check. If given it is checked if the not-installable revision is still installed."
245+
)
246+
parser.add_argument(
247+
"--add", default=False, action="store_true", help="Add new intstallable revisions if missing, default is not to add it and also keep the uninstallable one"
241248
)
242249
args = parser.parse_args()
243250

@@ -254,4 +261,4 @@ def fix_uninstallable(
254261
)
255262
handler.setFormatter(formatter)
256263

257-
fix_uninstallable(args.lockfile.name, args.toolshed, args.galaxy_url)
264+
fix_uninstallable(args.lockfile.name, args.toolshed, args.galaxy_url, args.add)

0 commit comments

Comments
 (0)