You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2025/03/21 12:49:01 UTC
(tooling-trusted-release) branch main updated: Allow --delete to be used with rsync
This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git
The following commit(s) were added to refs/heads/main by this push:
new 267cd7a Allow --delete to be used with rsync
267cd7a is described below
commit 267cd7addb642eeb7bdcf1f45facef08da57c863
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Fri Mar 21 14:48:50 2025 +0200
Allow --delete to be used with rsync
---
atr/ssh.py | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/atr/ssh.py b/atr/ssh.py
index ad4058f..14bd2f9 100644
--- a/atr/ssh.py
+++ b/atr/ssh.py
@@ -164,9 +164,6 @@ def _command_path_validate(path: str) -> tuple[str, str] | str:
def _command_simple_validate(argv: list[str]) -> str | None:
- if len(argv) != 5:
- return "There should be 5 arguments"
-
if argv[0] != "rsync":
return "The first argument should be rsync"
@@ -182,8 +179,19 @@ def _command_simple_validate(argv: list[str]) -> str | None:
if not argv[2][len(f"-{acceptable_options}.") :].isalpha():
return "The third argument should be a valid command"
- if argv[3] != ".":
- return "The fourth argument should be ."
+ # Support --delete as an optional argument before the path
+ if argv[3] != "--delete":
+ # No --delete, short command
+ if argv[3] != ".":
+ return "The fourth argument should be ."
+ if len(argv) != 5:
+ return "There should be 5 arguments"
+ else:
+ # Has --delete, long command
+ if argv[4] != ".":
+ return "The fifth argument should be ."
+ if len(argv) != 6:
+ return "There should be 6 arguments"
return None
@@ -192,7 +200,7 @@ async def _command_validate(process: asyncssh.SSHServerProcess) -> list[str] | N
def fail(message: str) -> list[str] | None:
# NOTE: Changing the return type to just None really confuses mypy
_LOGGER.error(message)
- process.stderr.write(f"ATR SSH error: {message}\n\n".encode())
+ process.stderr.write(f"ATR SSH error: {message}\nCommand: {process.command}\n".encode())
process.exit(1)
return None
@@ -207,7 +215,12 @@ async def _command_validate(process: asyncssh.SSHServerProcess) -> list[str] | N
if error:
return fail(error)
- result = _command_path_validate(argv[4])
+ if argv[3] == "--delete":
+ path_index = 5
+ else:
+ path_index = 4
+
+ result = _command_path_validate(argv[path_index])
if isinstance(result, str):
return fail(result)
path_project, path_version = result
@@ -234,9 +247,12 @@ async def _command_validate(process: asyncssh.SSHServerProcess) -> list[str] | N
return fail("You must be a member of this project's committee or a committer to upload to this release")
# Set the target directory to the release storage directory
- argv[4] = os.path.join(_CONFIG.STATE_DIR, "rsync-files", path_project, path_version)
+ argv[path_index] = os.path.join(_CONFIG.STATE_DIR, "rsync-files", path_project, path_version)
_LOGGER.info(f"Modified command: {argv}")
+ # Create the release's storage directory if it doesn't exist
+ await aiofiles.os.makedirs(argv[path_index], exist_ok=True)
+
return argv
@@ -249,9 +265,6 @@ async def _handle_client(process: asyncssh.SSHServerProcess) -> None:
if not argv:
return
- # Create the release's storage directory if it doesn't exist
- await aiofiles.os.makedirs(argv[4], exist_ok=True)
-
try:
# Create subprocess to actually run the command
# NOTE: asyncio base_events subprocess_shell requires cmd be str | bytes
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org