fetch-testdata fails when fetching a specific ref
Background
When creating new or modifying existing tests to use new testdata, we want to be able to check out a specific branch / tag / commit from the testdata repo. This currently fails.
Reproduction
# via Makefile
make fetch-testdata REF=7-fix-default-presets
# run directly
python3 ops/testdata/fetch-testdata.py --ref 7-fix-default-presets
Underlying issue
Information about the repo must be available whether it is already present locally or not. If a specific ref is given, the script would always attempt to use the local repo metadata before the cloning step. If the repo was not already cloned (as in CI), this would crash.
Implementation
-
add local/remote options for all git actions, or crash with informative error messages -
clone -
is_valid_commit
-
ref_type
,remote_ref_exists -> _lookup_ref
-
check if cwd
exists before running in_exec
, throwFileNotFoundError
if it doesn't
-
-
checkout a ref from an existing repo -
clone a new repo and checkout the target ref -
support use of --clean
and--ref
-
warns if ref not found, but in a shallow clone
Edited by Tor Solli-Nowlan