Skip to content

Instantly share code, notes, and snippets.

@zachelrath
Created June 26, 2024 14:21
Show Gist options
  • Save zachelrath/8046465d61be9048c694f3560b8d2c91 to your computer and use it in GitHub Desktop.
Save zachelrath/8046465d61be9048c694f3560b8d2c91 to your computer and use it in GitHub Desktop.
Require tag's commit to have been built off of main branch
#!/bin/bash
# Get the current commit SHA
current_commit_sha=$(git rev-parse HEAD)
# Get the SHA of the "origin/main" branch
origin_main_sha=$(git rev-parse origin/main)
# Check if the current commit SHA matches the "origin/main" SHA or any parent commit SHA
if git merge-base --is-ancestor $current_commit_sha $origin_main_sha; then
echo "Commit is on the main branch"
else
echo "Commit not found on main branch"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment