From 23d6e29d005c8d19fe10885c849f6dbb40e85602 Mon Sep 17 00:00:00 2001 From: Paulo Fidalgo Date: Fri, 26 Jun 2026 17:55:39 +0100 Subject: [PATCH 1/2] feat: harden git commits --- .github/workflows/changelog.yml | 23 +++++++++++++++++++++++ .github/workflows/commitlint.yml | 2 +- AGENTS.md | 21 ++++++++------------- Rakefile | 2 +- lefthook.yml | 10 ++++++++++ 5 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/changelog.yml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..8d9ae45 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,23 @@ +name: Changelog + +on: + pull_request: + push: + branches: [main] + +jobs: + changelog: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Validate git-cliff changelog generation + uses: orhun/git-cliff-action@v4 + with: + config: cliff.toml + args: --unreleased --verbose + env: + OUTPUT: /tmp/changelog-preview.md diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 3202dc7..9d0fd4b 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -3,7 +3,7 @@ name: Lint Commit Messages on: pull_request: push: - branches: [main, master] + branches: [main] jobs: commitlint: diff --git a/AGENTS.md b/AGENTS.md index 237414e..82b7c05 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -22,17 +22,12 @@ validated, and aligned with this gem's public API. - Before finishing release-harness changes, run the focused release tests and a `git-cliff` smoke check. -## Commit Messages +## Git Standards -- Use Conventional Commits: `feat`, `fix`, `docs`, `test`, `refactor`, or - `chore`. -- Keep the subject imperative, specific, and under 72 characters. -- Leave a blank line between the subject and body. -- Write one coherent reason per commit; split unrelated work first. -- Use the body when the reasoning matters. Explain why the change exists, - what approach was taken, and what constraints or side effects matter. -- Wrap body lines at 72 characters so commit hooks and terminal tools stay - readable. -- Avoid vague subjects such as `misc fixes`, `updates`, or `cleanup` unless - the cleanup is the actual scoped purpose. -- Mention verification in the body when it materially helps future readers. +- Use `main` as the canonical integration branch. +- Never commit directly to `main` or `master`. +- Use branches for all work. +- Use Conventional Commits with `What:`, `Why:`, and `Where:` in the body. +- Keep the subject specific and under 72 characters, with one blank line before + the body. +- Follow the `git-standards` skill for the full validation checklist. diff --git a/Rakefile b/Rakefile index 93454e8..68859a1 100644 --- a/Rakefile +++ b/Rakefile @@ -171,7 +171,7 @@ namespace :release do tag = release_tag(version) sh "git add CHANGELOG.md lib/git/markdown/version.rb" - sh %(git commit -m "chore(release): prepare v#{version}") + sh %(LEFTHOOK=0 git commit -m "chore(release): prepare v#{version}") sh %(git tag -a #{tag} -m "Release #{tag}") sh "git push origin #{branch}" sh "git push origin #{tag}" diff --git a/lefthook.yml b/lefthook.yml index 013dd7f..b78cc40 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -4,3 +4,13 @@ commit-msg: run: bundle exec commitlint --message {1} - name: standard run: bundle exec rake standard + +pre-commit: + jobs: + - name: protect-main-master + run: | + branch=$(git branch --show-current) + if [ "$branch" = "master" ] || [ "$branch" = "main" ]; then + echo "❌ Direct commits to '$branch' are not allowed. Use a feature branch." + exit 1 + fi From 860e9701b47a14c9968c69e9ab37db9d9c8921a4 Mon Sep 17 00:00:00 2001 From: Paulo Fidalgo Date: Fri, 26 Jun 2026 18:01:49 +0100 Subject: [PATCH 2/2] fix: standardrb offense --- lib/git/markdown/providers/github.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/git/markdown/providers/github.rb b/lib/git/markdown/providers/github.rb index 33a8a7b..87c29ed 100644 --- a/lib/git/markdown/providers/github.rb +++ b/lib/git/markdown/providers/github.rb @@ -33,9 +33,9 @@ def fetch_reviews(owner, repo, number) review.comments = all_pr_comments .select { |c| c["pull_request_review_id"] == review.id } .map do |data| - comment = Models::Comment.from_api(data) - comment.resolved = resolved_ids.include?(comment.id) - comment + comment = Models::Comment.from_api(data) + comment.resolved = resolved_ids.include?(comment.id) + comment end review end