Skip to content

cds get: --ref silently ignored when combined with --local (contradicts docs) #506

Description

@RonaldHensbergen

Summary

cds get --local <dir> is documented (CLI help text and README) as being
"mutually exclusive with --remote/--ref", but the actual mutual-exclusivity
check in cli/getter.py's _prepare_source_repository() only validates
remote:

if local is not None:
    if remote is not None:
        raise GetError("Specify only one of --remote and --local")
    yield _validate_source_repository(Path(local).expanduser())
    return

ref is never inspected in this branch. Since --ref defaults to "main"
(not None) on the CLI, there's no way to distinguish "user explicitly
passed --ref" from "using the default" -- but regardless, passing
--local together with an explicit --ref currently succeeds silently and
just ignores --ref, which contradicts the documented behavior.

Reproduction

cds get demo --local ./checkout --ref v2

This silently succeeds and copies from ./checkout at whatever state it's
currently in on disk -- --ref v2 has no effect and no warning/error is
raised, even though docs describe this combination as invalid.

Proposed fix

Pick one of:

  • Enforce the documented exclusivity: raise a GetError if local is set
    and ref differs from the default (DEFAULT_REF), similar to the
    existing --remote/--local check.
  • Or, if silently ignoring --ref with --local is fine, update the CLI
    help text (cli/main.py) and README to stop claiming --ref is mutually
    exclusive with --local.

Context

Raised during review of #493 (cds get GitHub tarball download), which
introduced --ref and --local flags. No existing test exercises the
--local + --ref combination.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliCLI commands and behaviorbugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions