Better resilience for fetching the tags

This commit is contained in:
David Heinemeier Hansson
2025-08-27 14:26:30 +02:00
parent b264c6540a
commit cf4e1c0eb7

View File

@@ -1,13 +1,18 @@
#!/bin/bash #!/bin/bash
# Ensure remote is reachable # Get remote tag
if ! git -C "$OMARCHY_PATH" ls-remote &>/dev/null; then latest_tag=$(git -C "$OMARCHY_PATH" ls-remote --tags origin | grep -v "{}" | awk '{print $2}' | sed 's#refs/tags/##' | sort -V | tail -n 1)
echo "Error: Unable to reach remote repository." if [[ -z "$latest_tag" ]]; then
echo "Error: Could not retrieve latest tag."
exit 1 exit 1
fi fi
latest_tag=$(git -C "$OMARCHY_PATH" ls-remote --tags origin | grep -v "{}" | awk '{print $2}' | sed 's#refs/tags/##' | sort -V | tail -n 1) # Get local tag
current_tag=$(git -C "$OMARCHY_PATH" describe --tags $(git -C "$OMARCHY_PATH" rev-list --tags --max-count=1)) current_tag=$(git -C "$OMARCHY_PATH" describe --tags $(git -C "$OMARCHY_PATH" rev-list --tags --max-count=1))
if [[ -z "$current_tag" ]]; then
echo "Error: Could not retrieve current tag."
exit 1
fi
if [[ "$current_tag" != "$latest_tag" ]]; then if [[ "$current_tag" != "$latest_tag" ]]; then
echo "Omarchy update available ($latest_tag)" echo "Omarchy update available ($latest_tag)"