this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

build: Add a commit helper script

+131 -6
+2
README.md
··· 78 78 79 79 Commits should conform to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. 80 80 81 + A script to help create conforming commits is provided in `bin/commit.sh`, or via `task commit`. 82 + 81 83 ### Test Coverage 82 84 83 85 PRs that improve the test coverage are encouraged.
+17 -6
Taskfile.yml
··· 2 2 3 3 version: "3" 4 4 5 - method: timestamp 5 + vars: 6 + BIN: "{{.ROOT_DIR}}/bin" 6 7 7 8 tasks: 8 9 default: ··· 13 14 cmd: act 14 15 ci:local: 15 16 desc: Run CI locally 16 - deps: [audit, fmt, test, nix:check, nix:build, clippy, pre-commit] 17 + deps: [audit, fmt, test, nix:check, nix:build, clippy, pre-commit, build] 17 18 nix:check: 18 19 desc: Run Nix CI checks 19 20 sources: 20 - - "./**/*" 21 + - ./**/* 21 22 cmds: 22 23 - nix flake check 23 24 nix:build: ··· 27 28 clippy: 28 29 desc: Run clippy 29 30 sources: 30 - - "./**/*.rs" 31 + - ./**/*.rs 31 32 cmd: cargo clippy 32 33 pre-commit: 33 34 desc: Run pre-commit ··· 35 36 fmt: 36 37 desc: Run all formatters 37 38 sources: 38 - - "./**/*.rs" 39 + - ./**/*.rs 39 40 cmd: cargo fmt --all 40 41 test: 41 42 desc: Run all tests 42 43 aliases: [t] 43 44 sources: 44 - - "./**/*.rs" 45 + - ./**/*.rs 45 46 cmd: cargo nextest run 46 47 audit: 47 48 desc: Run cargo security audit ··· 49 50 - Cargo.lock 50 51 - flake.lock 51 52 cmd: cargo audit 53 + build: 54 + desc: Build the project 55 + aliases: [b] 56 + sources: 57 + - ./**/*.rs 58 + - ./Cargo* 59 + cmd: cargo build 60 + commit: 61 + desc: Commit changes using custom script 62 + cmd: "{{.BIN}}/commit.sh"
+111
bin/commit.sh
··· 1 + #!/usr/bin/env bash 2 + 3 + set -euo pipefail 4 + 5 + # Create commit interactively 6 + 7 + # conforms commits to https://www.conventionalcommits.org/en/v1.0.0/ standards 8 + 9 + # TODO: add support for breaking change 10 + 11 + # Check if there are any staged changes 12 + if [[ -z $(git diff --staged --name-only) ]]; then 13 + gum style --foreground=1 --bold "No staged changes." 14 + exit 0 15 + fi 16 + 17 + # Print the staged files 18 + gum style --foreground=5 "Staged files:" 19 + git diff --staged --name-status 20 + 21 + gum confirm "Show full diff?" && git diff --staged 22 + 23 + # Runs pre-commit on all staged files 24 + if [ -x "$(command -v pre-commit)" ]; then 25 + gum style --foreground=5 "Run pre-commit:" 26 + pre-commit run 27 + fi 28 + 29 + gum style --foreground=5 "Configure commit message:" 30 + 31 + TYPE=$(gum choose "help" "breaking" "build" "change" "chore" "ci" "deprecate" "docs" "feat" "fix" "perf" "refactor" "remove" "revert" "security" "style" "test") 32 + if [ "$TYPE" = "help" ]; then 33 + # Descriptions largely taken from: https://medium.com/neudesic-innovation/conventional-commits-a-better-way-78d6785c2e08 34 + echo "# Commit types 35 + ## breaking 36 + A commit that has a footer BREAKING CHANGE:, or appends a ! after the 37 + type/scope, introduces a breaking API change (correlating with MAJOR in 38 + semantic versioning). A BREAKING CHANGE can be part of commits of any type. 39 + 40 + ## build 41 + Changes that affect the build system or external dependencies (example scopes: 42 + nix, rust) 43 + 44 + ## change 45 + The commit changes the implementation of an existing feature. 46 + 47 + ## chore 48 + The commit includes a technical or preventative maintenance task that is 49 + necessary for managing the product or the repository, but it is not tied to any 50 + specific feature or user story. For example, releasing the product can be 51 + considered a chore. Regenerating generated code that must be included in the 52 + repository could be a chore. 53 + 54 + ## ci 55 + Changes to our CI configuration files and scripts 56 + 57 + ## deprecate 58 + The commit deprecates existing functionality, but does not remove it from the 59 + product. 60 + 61 + ## docs 62 + The commit adds, updates, or revises documentation that is stored in the 63 + repository. 64 + 65 + ## feat 66 + A new feature 67 + 68 + ## fix 69 + A bug fix 70 + 71 + ## perf 72 + A code change that improves performance, but not functionality. 73 + 74 + ## refactor 75 + A code change that neither fixes a bug nor adds a feature 76 + 77 + ## remove 78 + The commit removes a feature from the product. Typically features are 79 + deprecated first for a period of time before being removed. Removing a feature 80 + from the product may be considered a breaking change that will require a major 81 + version number increment. 82 + 83 + ## revert 84 + Reverts a previous commit 85 + 86 + ## security 87 + The commit improves the security of the product or resolves a security issue 88 + that has been reported. 89 + 90 + ## style 91 + Changes that do not affect the meaning of the code (comments, white-space, 92 + formatting, missing semi-colons, etc) 93 + 94 + ## test 95 + The commit enhances, adds to, revised, or otherwise changes the suite of 96 + automated tests for the product." | gum format | gum pager 97 + 98 + TYPE=$(gum choose "breaking" "build" "change" "chore" "ci" "deprecate" "docs" "feat" "fix" "perf" "refactor" "remove" "revert" "security" "style" "test") 99 + fi 100 + 101 + SCOPE=$(gum input --placeholder "scope") 102 + 103 + # Since the scope is optional, wrap it in parentheses if it has a value. 104 + test -n "$SCOPE" && SCOPE="($SCOPE)" 105 + 106 + # Pre-populate the input with the type(scope): so that the user may change it 107 + SUMMARY=$(gum input --value "$TYPE$SCOPE: " --placeholder "Summary of this change") 108 + DESCRIPTION=$(gum write --placeholder "Details of this change (CTRL+D to finish)") 109 + 110 + # Commit these changes 111 + gum confirm "Commit changes?" && git commit -m "$SUMMARY" -m "$DESCRIPTION"
+1
flake.nix
··· 142 142 deadnix 143 143 git-cliff 144 144 go-task 145 + gum # Pretty printing in scripts 145 146 nodePackages.prettier 146 147 statix 147 148