Commit graph

80 commits

Author SHA1 Message Date
Sven van Heugten
34d61e4906 Merge pull request 'Introduce a small DSL' (#17) from dsl into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/17
2026-04-16 17:24:41 +02:00
967bb580e6
Remove some newlines in the README 2026-04-16 17:24:00 +02:00
fc7c23355a
Be less verbose
The output is already printed once anyway.

```git-check-assertions
[success] ./test/git-check-assertions.bats
```
2026-04-16 17:24:00 +02:00
0719fa33c2
Support ✓/✗ as alternatives to [success]/[failure] 2026-04-16 17:23:59 +02:00
4704cc088d
Introduce a DSL to replace the plain bash scripts
It's really important for `git-check-assertions` blocks to be 'obviously
correct', so that we don't need to... test the tests that test the tests.

Let's introduce a little DSL that is less error-prone than a plain bash
script.
2026-04-16 17:23:59 +02:00
ad10b2cc4c
Execute the assertion blocks with Python instead 2026-04-15 21:03:02 +02:00
d92713930e
Wrap assertion checking in a function 2026-04-15 20:49:16 +02:00
ad5a6985ba
Merge branch 'readme-fixes' 2026-03-13 06:16:15 +01:00
1543d47f6e
Update article name 2026-03-13 06:14:57 +01:00
0cdf9a73c6
Fix typos in README 2026-03-13 06:14:03 +01:00
Sven van Heugten
ac6000d1ee Merge pull request 'Add support for multiple git-check-assertions blocks in one commit message' (#16) from multiple-blocks into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/16
2026-03-11 23:04:29 +01:00
3dc9930dbb
Make run stream the output 2026-03-11 23:02:38 +01:00
69f8acad8f
Print block number and remove redundant commit hash 2026-03-11 23:02:38 +01:00
32871dc261
Remove redundant newline 2026-03-11 23:02:38 +01:00
e5baffa698
Document support for multiple git-check-assertion blocks 2026-03-11 23:02:37 +01:00
35584c9aa7
Restore the commit between assertion blocks
```git-check-assertions
run ./test/git-check-assertions.bats
assert_success

git checkout HEAD~ bin
run ./test/git-check-assertions.bats
assert_failure
assert_output --partial "not ok 10 should restore the commit between assertion blocks in one commit message"
```
2026-03-11 22:41:44 +01:00
7e483b8a7f
Add support for multiple git-check-assertions blocks 2026-03-11 22:41:44 +01:00
Sven van Heugten
80ff74cdf9 Merge pull request 'Fix build' (#15) from fix-build into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/15
2026-03-10 17:44:27 +01:00
d8c1e7a2c8
Don't copy from $src since it makes patching impossible 2026-03-10 17:42:52 +01:00
210dd4d72d
Fix build
```git-check-assertions
run nix build
assert_success

git checkout HEAD~
run nix build
assert_failure
assert_output --partial "done <.git-check-assertions-cache"
```
2026-03-10 17:39:25 +01:00
Sven van Heugten
1080fc60fd Merge pull request 'Cache successful commits' (#14) from cache into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/14
2026-03-10 06:50:28 +01:00
e647b2599b
Cache successful commits
```git-check-assertions
run test/git-check-assertions.bats
assert_success

git checkout HEAD~1 bin
run test/git-check-assertions.bats
assert_failure
assert_output --partial "file exists, but it was expected to be absent"
```
2026-03-10 06:49:23 +01:00
Sven van Heugten
f3444c3d55 Merge pull request 'Put flake instructions in a <details> block' (#13) from condense-readme into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/13
2026-03-06 18:44:04 +01:00
bf26f40261
Put flake instructions in a <details> block 2026-03-06 18:42:00 +01:00
fea90637e3
Print a message when all went well 2026-03-06 17:50:28 +01:00
Sven van Heugten
d90e2eebc3 Merge pull request 'Make 'run' print the command output' (#12) from print-run-output into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/12
2026-03-06 05:24:12 +01:00
495f6757dd
Make 'run' print the command output
```git-check-assertions
run test/git-check-assertions.bats
assert_success

git checkout HEAD~1 bin
run test/git-check-assertions.bats
assert_failure
```
2026-03-06 05:21:50 +01:00
Sven van Heugten
b3db4fcf2b Merge pull request 'Check initial state before running' (#11) from check-initial-state into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/11
2026-03-06 05:15:16 +01:00
a31bc62046
Check initial state before running
```git-check-assertions
run test/git-check-assertions.bats
assert_success

git checkout HEAD~1 bin
run test/git-check-assertions.bats
assert_failure
assert_output --partial "not ok 2 should refuse to run when the index has changes"
assert_output --partial "not ok 3 should refuse to run when the working tree has changes"
assert_output --partial "not ok 4 should refuse to run when there are untracked files"
```
2026-03-06 05:12:00 +01:00
Sven van Heugten
3ce1ea5e4b Merge pull request 'Restore the index after every commit' (#10) from restore-index into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/10
2026-03-06 04:51:22 +01:00
dc74688ce9
Restore the index after every commit
```git-check-assertions
run ./test/git-check-assertions.bats
assert_success
```
2026-03-06 04:47:28 +01:00
1ec02587b0
Demonstrate that the index isn't restored
```git-check-assertions
run ./test/git-check-assertions.bats
assert_failure
assert_output --partial "not ok 9 should restore index when finished"
assert_output --partial "not ok 10 should restore index between commits"
assert_output --partial "not ok 11 should restore index after a failure"
assert_output --partial "not ok 13 you can use git checkout in an assertion to assert against a mixed version of the code"
```
2026-03-06 04:44:32 +01:00
d4d25dd784
Slightly improve examples 2026-03-04 08:05:49 +01:00
Sven van Heugten
8de5bee57f Merge pull request 'Add support for when the base branch is called master' (#9) from support-base-branch-master into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/9
2026-03-04 08:01:49 +01:00
9ecec1ee6d
Add support for when the base branch is called master
```git-check-assertions
run ./test/git-check-assertions.bats
assert_success
```
2026-03-04 07:58:37 +01:00
e495aa826e
Add a failing test to show that master isn't supported
```git-check-assertions
run ./test/git-check-assertions.bats
assert_failure
assert_output --partial "fatal: Not a valid object name main"
```
2026-03-04 07:57:12 +01:00
fcea18e820
Add a real-world example to the README 2026-03-04 07:48:26 +01:00
Sven van Heugten
cb74f351f7 Merge pull request 'Restore the worktree after a failure' (#8) from restore-worktree-after-failure into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/8
2026-03-04 07:46:58 +01:00
2299ee3407
Restore the worktree after a failure
```git-check-assertions
run ./test/git-check-assertions.bats
assert_success
```
2026-03-04 07:40:23 +01:00
99bcd7460f
Add failing test to check if the worktree is restored after failure
This test currently doesn't pass:

```git-check-assertions
run ./test/git-check-assertions.bats
assert_failure
assert_output --partial "file is greater than 0 byte"
```
2026-03-04 07:38:06 +01:00
Sven van Heugten
6963d06363 Merge pull request 'Add partial change example' (#7) from add-partial-change-example into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/7
2026-03-04 07:32:41 +01:00
d8e758387c
Add partial change example
```git-check-assertions
sed -i 's/HEAD~/HEAD/' test/git-check-assertions.bats
run test/git-check-assertions.bats
assert_failure
assert_output --partial "Expected command to fail, but it succeeded."
```
2026-03-04 07:27:46 +01:00
66a30d61cf
Fix typo 2026-03-04 07:03:47 +01:00
Sven van Heugten
a330b66ad0 Merge pull request 'Add better helper functions' (#6) from better-helper-functions into main
Reviewed-on: https://codeberg.org/svenvanheugten/git-check-assertions/pulls/6
2026-03-03 21:15:02 +01:00
4eadcbe437
Document the helper functions 2026-03-03 21:14:08 +01:00
d244a706f3
Remove old assert_fails 2026-03-03 20:32:22 +01:00
523df74b72
Use the new functions in the README examples 2026-03-03 20:32:14 +01:00
3036d6d37e
Introduce --partial on assert_output 2026-03-03 20:29:39 +01:00
475b0c6fa1
Verify that stderr is taken into account 2026-03-03 20:28:17 +01:00
b57d527d6e
Introduce assert_output 2026-03-03 20:26:07 +01:00