Skip to content

Commit

Permalink
Add script for downloading a branch or tag of sdm_schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyMcCormick committed Oct 2, 2024
1 parent b5843be commit cde423c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docker/scripts/download-sdm-schemas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

_url=https://github.com/lsst/sdm_schemas.git

# Make sure SDM_SCHEMAS_REF is set with default
if [ -z "$SDM_SCHEMAS_REF" ]; then
SDM_SCHEMAS_REF=main
fi

echo "Cloning SDM schemas from $_url at $SDM_SCHEMAS_REF"

# Determine if SDM_SCHEMAS_REF is a branch or a tag
if git ls-remote --heads "$_url" "$SDM_SCHEMAS_REF" | grep -q "$SDM_SCHEMAS_REF"; then
echo "$SDM_SCHEMAS_REF is a branch"
git clone --depth=1 --branch "$SDM_SCHEMAS_REF" "$_url"
elif git ls-remote --tags "$_url" "$SDM_SCHEMAS_REF" | grep -q "refs/tags/$SDM_SCHEMAS_REF"; then
echo "$SDM_SCHEMAS_REF is a tag"
git clone --depth=1 "$_url"
pushd sdm_schemas
git checkout tags/"$SDM_SCHEMAS_REF"
popd
else
echo "Error: $SDM_SCHEMAS_REF is neither a branch nor a tag."
exit 1
fi

0 comments on commit cde423c

Please sign in to comment.