🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore: adds git hooks to protect main branch (#2288)
Hassieb Pakzada60bf7ce559b
diff --git a/.husky/pre-commit b/.husky/pre-commitnew file mode 100755index 0000000000..021f62e8ab--- /dev/null+++ b/.husky/pre-commit@@ -0,0 +1,22 @@+#!/bin/sh++# Get the current branch+current_branch=$(git rev-parse --abbrev-ref HEAD)++# Define the protected branch+protected_branch="main"++# Check if the current branch is the protected branch+if [ "$current_branch" = "$protected_branch" ]; then+ echo "🚨 You are about to commit to the $protected_branch branch. Are you sure? (y/n)"+ read -r answer < /dev/tty+ if [ "$answer" != "${answer#[Yy]}" ]; then+ exit 0 # Commit will proceed+ else+ echo "Commit to $protected_branch branch has been canceled."+ exit 1 # Commit will be blocked+ fi+fi++# If not the protected branch, proceed with the commit+exit 0diff --git a/.husky/pre-push b/.husky/pre-pushnew file mode 100755index 0000000000..6c8c7436ca--- /dev/null+++ b/.husky/pre-push@@ -0,0 +1,22 @@+#!/bin/sh++# Get the current branch+current_branch=$(git rev-parse --abbrev-ref HEAD)++# Define the protected branch+protected_branch="main"++# Check if the current branch is the protected branch+if [ "$current_branch" = "$protected_branch" ]; then+ echo "🚨 You are about to push to the $protected_branch branch. Are you sure? (y/n)"+ read -r answer < /dev/tty+ if [ "$answer" != "${answer#[Yy]}" ]; then+ exit 0 # Push will proceed+ else+ echo "Push to $protected_branch branch has been canceled."+ exit 1 # Push will be blocked+ fi+fi++# If not the protected branch, proceed with the push+exit 0diff --git a/package.json b/package.jsonindex 1bbd511f62..d9cd63e191 100644--- a/package.json+++ b/package.json@@ -24,11 +24,13 @@"lint": "turbo run lint","test": "turbo run test","models:migrate": "turbo run models:migrate",- "release": "dotenv -e ../.env -- release-it"+ "release": "dotenv -e ../.env -- release-it",+ "prepare": "husky"},"devDependencies": {"@release-it/bumper": "^6.0.1","dotenv-cli": "^7.4.2",+ "husky": "^9.0.11","prettier": "^3.2.5","release-it": "^17.2.1","turbo": "^1.13.3"diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 765f2b3ecf..7309474fe1 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -14,6 +14,9 @@ importers:dotenv-cli:specifier: ^7.4.2version: 7.4.2+ husky:+ specifier: ^9.0.11+ version: 9.0.11prettier:specifier: ^3.2.5version: 3.2.5@@ -11098,6 +11101,12 @@ packages:ms: 2.1.3dev: false+ resolution: {integrity: sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==}+ engines: {node: '>=18'}+ hasBin: true+ dev: true+resolution: {integrity: sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ==}dev: false