Skip to content

Commit

Permalink
test: Improve logging and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jhf committed Sep 10, 2024
1 parent 32a4432 commit be29e89
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions devops/manage-statbus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,30 @@ case "$action" in
exit 1
fi

# Fetch latest changes from the remote,
# before validating the commit, as it must first
# be fetched.
git fetch origin

# Check if commit is valid and provided
# Validate that the commit is provided and non-empty
if [ -z "$COMMIT" ]; then
echo "Error: Commit hash must be provided."
exit 1
elif ! git cat-file -e "$COMMIT" 2>/dev/null; then
fi

# Check if the commit exists in the repository
if ! git cat-file -e "$COMMIT" 2>/dev/null; then
echo "Error: Commit '$COMMIT' is invalid or not found."
exit 1
fi

# Log the branch and commit being used for debugging
echo "Checking out branch '$BRANCH' at commit '$COMMIT'"

# Create or reset the local branch with the given name, using the specified commit
git checkout -B "$BRANCH" "$COMMIT"
fi

# Proceed with the rest of the workflow
./devops/manage-statbus.sh create-db

Expand Down

0 comments on commit be29e89

Please sign in to comment.