Quote remote release-tool command arguments#402
Conversation
|
@e-q Overall comment: Instead of introducing |
|
Gotcha, I refactored this so the SSH helpers now accept command argument lists and call For the two places that intentionally need remote shell glob expansion, the updated version uses static |
|
This now has a conflict after the merge of #406. |
Refactor SSH command helpers to accept command argument lists and join them at the execution boundary with shlex.join(). Keep the two intentional wildcard operations as static sh -c snippets with dynamic paths passed as positional arguments, so glob expansion remains explicit without quoting values at each call site. Validation: tox -q -e py313 -- -k 'run_add_to_python_dot_org_quotes_remote_environment or upload_files_to_server_quotes_remote_cleanup_path or release_file_placement_quotes_remote_paths or remote_upload_commands_quote_url_derived_paths'; tox -q -e py313 -- tests/test_run_release.py tests/test_windows_merge_upload.py; tox -q -e mypy; tox -q -e lint.
be6b586 to
7c5dbae
Compare
|
Rebased onto current |
sethmlarson
left a comment
There was a problem hiding this comment.
Only had one small comment, otherwise LGTM.
|
CI failures not related to this PR, addressed in #411 |
Hmm, sometimes when needing to debug stuff, it's easier to have a command as a string like Is it possible to safely have them as strings as a starting point? |
|
@hugovk What do you think of a static shell template + quoted substitutions helper: from string import Template
from typing import LiteralString
def join_remote_template(template: LiteralString, **values: object) -> str:
quoted = {name: shlex.quote(str(value)) for name, value in values.items()}
return Template(template).substitute(quoted)Then call sites can stay copy/pasteable: execute_command("chgrp -R docs $destination", destination=destination)
execute_command("chmod -R 775 $destination", destination=destination)
execute_command(
"find $destination -type f -exec chmod 664 {} \\;",
destination=destination,
)
execute_command("cp $source/* $destination", source=source, destination=destination)This way you can copy-paste shell-looking strings, while dynamic values are still quoted centrally. I’d use |
|
@e-q Looks good. @sethmlarson ok for you? |
Summary
Closes #397 (release tooling remote command arguments)
Closes #401 (Windows upload URL-derived remote paths)
Testing
tox -q -e mypy: passed.