From 84a0803f42a52bf7b93fc53d04aa1336642a7a75 Mon Sep 17 00:00:00 2001 From: Chris Geyer Date: Fri, 22 May 2026 01:04:15 +0000 Subject: [PATCH] fix: populate git fields and duration on roar get jobs roar get created job records without git_commit, git_branch, git_repo, or duration_seconds. The GLaaS API requires duration_seconds to be a number (not null) and uses git fields for session context. Also adds -n/--name step_name support to get. Co-Authored-By: Claude Opus 4.6 (1M context) --- roar/application/get/service.py | 32 ++++++++++++++++++++++++++++++++ roar/cli/commands/get.py | 8 +++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/roar/application/get/service.py b/roar/application/get/service.py index d1b845a..f3b403f 100644 --- a/roar/application/get/service.py +++ b/roar/application/get/service.py @@ -59,12 +59,40 @@ def get_artifacts(request: GetRequest) -> GetResponse: except Exception: pass + git_branch = None + git_repo_url = None + if not request.dry_run: + try: + import subprocess + + git_branch = ( + subprocess.check_output( + ["git", "rev-parse", "--abbrev-ref", "HEAD"], + cwd=str(repo_root), + stderr=subprocess.DEVNULL, + text=True, + ).strip() + or None + ) + git_repo_url = ( + subprocess.check_output( + ["git", "remote", "get-url", "origin"], + cwd=str(repo_root), + stderr=subprocess.DEVNULL, + text=True, + ).strip() + or None + ) + except Exception: + pass + with create_database_context(request.roar_dir) as db_ctx: service = GetService( backend=backend, source=parsed_source, repo_root=repo_root, ) + t0 = time.time() transfer_result = service.get( destination=request.destination, expected_hash=request.expected_hash, @@ -72,6 +100,7 @@ def get_artifacts(request: GetRequest) -> GetResponse: force=request.force, is_prefix=is_prefix, ) + download_duration = time.time() - t0 result = _materialize_get_result( db_ctx=db_ctx, @@ -81,6 +110,7 @@ def get_artifacts(request: GetRequest) -> GetResponse: git_commit=git_commit, git_branch=git_branch, git_repo=git_repo_url, + duration_seconds=download_duration, ) git_tag_name = None @@ -120,6 +150,7 @@ def _materialize_get_result( git_commit: str | None, git_branch: str | None = None, git_repo: str | None = None, + duration_seconds: float = 0.0, ) -> GetResponse: if transfer_result.dry_run or not transfer_result.success: return GetResponse( @@ -159,6 +190,7 @@ def _materialize_get_result( git_commit=git_commit, git_branch=git_branch, git_repo=git_repo, + duration_seconds=duration_seconds, step_name=request.step_name, ) return GetResponse( diff --git a/roar/cli/commands/get.py b/roar/cli/commands/get.py index 1440bca..2793e6f 100644 --- a/roar/cli/commands/get.py +++ b/roar/cli/commands/get.py @@ -55,7 +55,13 @@ is_flag=True, help="Show what would be downloaded without doing it.", ) -@click.option("-n", "--name", "step_name", help="Set the name label for this step.") +@click.option( + "-n", + "--name", + "step_name", + default=None, + help="Set the name label for this step.", +) @click.pass_obj @require_init def get(