From 5c0bc9561e4a1e8d2106b2258b5ffe4b9dce60d6 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Fri, 18 Apr 2025 22:06:08 +0200 Subject: [PATCH] chore: Use `committed` instead of `conventional-pre-commit` The most important difference in this PR is that we now enforce scope and subject line length. `conventional-pre-commit`, which we have been using until now, does not appear to allow that unlike `committed` which we will be now using. On the other hand, `committed` doesn't allow to require having a scope, unlike `conventional-pre-commit`, but I will probably submit them a PR for this later. I also find it questionable that disabling particular checks is to be done by switching boolean options to false. Doing so by string options would be more future-proof. Also note that this has a check to make sure the commit message starts with a verb. I am fine with this myself, but it may be an overkill. --- .pre-commit-config.yaml | 7 ++- .woodpecker/check_formatting.yaml | 2 + committed.toml | 73 +++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 committed.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b068313..42b329b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,9 +14,8 @@ repos: rev: v5.0.2 hooks: - id: reuse-lint-file -- repo: https://github.com/compilerla/conventional-pre-commit - rev: v3.4.0 +- repo: https://github.com/crate-ci/committed + rev: v1.1.7 hooks: - - id: conventional-pre-commit + - id: committed stages: [commit-msg] - args: [] diff --git a/.woodpecker/check_formatting.yaml b/.woodpecker/check_formatting.yaml index ae15e67..358faff 100644 --- a/.woodpecker/check_formatting.yaml +++ b/.woodpecker/check_formatting.yaml @@ -9,6 +9,8 @@ steps: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always commands: + - cargo install committed + - committed develop..HEAD - rustup component add rustfmt - cargo fmt --all -- --check when: diff --git a/committed.toml b/committed.toml new file mode 100644 index 0000000..7012cd9 --- /dev/null +++ b/committed.toml @@ -0,0 +1,73 @@ +# SPDX-FileCopyrightText: 2025 Topola contributors +# +# SPDX-License-Identifier: MIT + +subject_length = 80 +line_length = 100 +style = "conventional" + +# Should be the same as the list of directories in crates/ and src/. +allowed_scopes = [ + # Generated using `ls crates | awk '{ print "\"" $1 "\","; }' | sort`. + "planar-incr-embed", + "specctra-core", + "specctra_derive", + "topola-cli", + "topola-egui", + + # Generated using + # `find src -type f | awk '!/lib.rs|mod.rs/ { print "\"" substr($1, 1 + 4, length($1) - 4 - 3) "\","; }' | sort`. + "autorouter/autoroute", + "autorouter/autorouter", + "autorouter/compare_detours", + "autorouter/execution", + "autorouter/history", + "autorouter/invoker", + "autorouter/measure_length", + "autorouter/place_via", + "autorouter/pointroute", + "autorouter/ratsnest", + "autorouter/remove_bands", + "autorouter/selection", + "drawing/band", + "drawing/bend", + "drawing/cane", + "drawing/collect", + "drawing/dot", + "drawing/drawing", + "drawing/gear", + "drawing/graph", + "drawing/guide", + "drawing/head", + "drawing/loose", + "drawing/primitive", + "drawing/seg", + "geometry/compound", + "geometry/edit", + "geometry/geometry", + "geometry/poly", + "geometry/primitive", + "geometry/recording_with_rtree", + "geometry/shape", + "geometry/with_rtree", + "graph", + "interactor/activity", + "interactor/interaction", + "interactor/interactor", + "layout/layout", + "layout/poly", + "layout/via", + "math/tangents", + "router/astar", + "router/draw", + "router/navcord", + "router/navcorder", + "router/navmesh", + "router/route", + "router/router", + "specctra/design", + "stepper", + "triangulation" +] + +merge_commit = false