From 7576f6ed90ae95ddea2e4869312dfa21686545bb Mon Sep 17 00:00:00 2001 From: Joe Heffer Date: Thu, 12 Feb 2026 11:59:50 +0000 Subject: [PATCH] chore: add standardised branch name rule set https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/creating-rulesets-for-a-repository https://conventional-branch.github.io/ --- .../rulesets/conventional-branch-naming.json | 47 +++++++++++++++++++ CLAUDE.md | 14 +++++- CONTRIBUTING.md | 20 ++++++-- 3 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 .github/rulesets/conventional-branch-naming.json diff --git a/.github/rulesets/conventional-branch-naming.json b/.github/rulesets/conventional-branch-naming.json new file mode 100644 index 00000000..8c676d55 --- /dev/null +++ b/.github/rulesets/conventional-branch-naming.json @@ -0,0 +1,47 @@ +{ + "name": "Conventional Branch Naming", + "target": "branch", + "enforcement": "active", + "conditions": { + "ref_name": { + "exclude": [ + "refs/heads/main", + "refs/heads/master", + "refs/heads/develop", + "refs/heads/staging", + "refs/heads/production" + ], + "include": [ + "~ALL" + ] + } + }, + "rules": [ + { + "type": "creation", + "parameters": { + "restricted_ref_names": { + "patterns": [ + { + "operator": "regex", + "pattern": "^(?!refs/heads/(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)/.+$).*" + } + ] + } + } + }, + { + "type": "update", + "parameters": { + "update_allows_fetch_and_merge": true + } + } + ], + "bypass_actors": [ + { + "actor_id": 5, + "actor_type": "RepositoryRole", + "bypass_mode": "always" + } + ] +} diff --git a/CLAUDE.md b/CLAUDE.md index 4f5b4d11..ac5fa3a7 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -196,7 +196,19 @@ Components use Bootstrap 5 for styling and Chart.js for visualizations. ### Branching Strategy - **main branch**: Primary branch for all development and production -- Branch naming: Use semantic prefixes (`feat/`, `fix/`, `docs/`, etc.) +- **Branch naming**: Must follow [conventional branch naming](https://conventional-branch.github.io/) with these prefixes: + - `feat/` - New features + - `fix/` - Bug fixes + - `docs/` - Documentation changes + - `style/` - Code style changes (formatting, whitespace) + - `refactor/` - Code refactoring without changing behavior + - `perf/` - Performance improvements + - `test/` - Test additions or changes + - `build/` - Build system or dependency changes + - `ci/` - CI/CD configuration changes + - `chore/` - Maintenance tasks + - `revert/` - Revert previous commits +- **Enforcement**: GitHub rulesets enforce conventional branch naming for all branches (except `main`, `develop`, `staging`, `production`) ### Making Changes diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 17759481..c411102e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,9 +15,23 @@ Please use the [Kanban board](https://github.com/orgs/RSE-Sheffield/projects/19) 1. [Raise an issue](https://github.com/RSE-Sheffield/SORT/issues/new?template=Blank+issue) clearly describing the problem or user requirements; 2. [Create a branch](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/creating-a-branch-for-an-issue) - that is associated with that issue. It can be helpful to prefix the branch name to match the type of changes - e.g. `feat/123-my-feature` for features or `docs/my-guide` for documentation, etc. - See [Semantic branch names](https://damiandabrowski.medium.com/semantic-branch-names-and-commit-messages-3ac38a6fcbb6). + that is associated with that issue. Branch names must follow [conventional branch naming](https://conventional-branch.github.io/) + with one of these prefixes: + - `feat/` - New features + - `fix/` - Bug fixes + - `docs/` - Documentation changes + - `style/` - Code style changes (formatting, whitespace) + - `refactor/` - Code refactoring without changing behavior + - `perf/` - Performance improvements + - `test/` - Test additions or changes + - `build/` - Build system or dependency changes + - `ci/` - CI/CD configuration changes + - `chore/` - Maintenance tasks and other changes + - `revert/` - Revert previous commits + + Examples: `feat/123-user-authentication`, `fix/survey-validation`, `docs/deployment-guide` + + Note: GitHub branch protection rules enforce this naming convention for all branches except `main`, `develop`, `staging`, and `production`. 3. In that branch, make changes that aim to resolve that issue; 4. Create a [draft pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests) (