Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/holo 98 enforce ticket linking #59

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Get the current branch name
branch_name=$(git rev-parse --abbrev-ref HEAD)

# Define the allowed branch name pattern
pattern='^(feature|bugfix|hotfix|release)\/HOLO-[0-9]+'

if [[ ! $branch_name =~ $pattern ]]; then
echo "❌ Error: Invalid branch name '$branch_name'"
echo "✅ Expected format: feature/HOLO-123-description"
exit 1 # Block commit
fi

echo "✅ Branch name '$branch_name' is valid. Commit allowed."
exit 0 # Allow commit
18 changes: 18 additions & 0 deletions .github/workflows/enforce-branch-name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Enforce Branch Naming

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
validate-branch-name:
runs-on: ubuntu-latest
steps:
- name: Check Branch Name
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
if [[ ! "$BRANCH_NAME" =~ ^(feature|bugfix|hotfix|release)\/HOLO-[0-9]+ ]]; then
echo "❌ Invalid branch name: $BRANCH_NAME"
echo "✅ Expected: feature/HOLO-123-description"
exit 1
fi
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ log = "0.4.17"
opt-level = "z"

[profile.release]
opt-level = "z"
opt-level = "z"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This is an experiment to contain the code for all components in a single repository, also known as a monorepository.

Please run `sh setup-hooks.sh` to enforce correct naming convention for branches.

## Repository Layout

The code is grouped by language or framework name.
Expand Down
18 changes: 18 additions & 0 deletions setup-hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Define source and destination paths
SRC_FILE=".github/hooks/pre-commit"
DEST_FILE=".git/hooks/pre-commit"

# Ensure the .git/hooks directory exists
mkdir -p .git/hooks

# Copy the pre-commit hook
if [ -f "$SRC_FILE" ]; then
cp "$SRC_FILE" "$DEST_FILE"
chmod +x "$DEST_FILE"
echo "✅ Pre-commit hook installed successfully!"
else
echo "❌ Error: $SRC_FILE does not exist!"
exit 1
fi