-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script for downloading a branch or tag of sdm_schemas
- Loading branch information
1 parent
b5843be
commit cde423c
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |