Fossil Forum

aminom 2 weeks, 1 day ago

Post: Suggestion: run before-commit hooks during --dry-run commits

Problem: before-commit hooks are not run during a --dry-run commit.

Why I think this is a problem

  • It makes it hard to test before-commit hooks without making real commits.
  • It is not documented anywhere.
  • The current hooks documentation recommends using a --dry-run commit to test a before-commit hook, which doesn't work.

How I think it should work instead

  • fossil commit --dry-run should do a dry run commit and run the hooks, failing the dry run commit if any hook exits with non-zero.
  • fossil commit --dry-run --no-verify should to a dry run commit and skip running the hooks.

Reproduction steps

Set up test checkout:

$ mkdir test
$ cd test
$ fossil init test.fossil
$ fossil open test.fossil
$ touch test1.txt
$ fossil add test1.txt

Set up hooks:

$ fossil hook add --command "echo '0xBADF00D'" --type 'before-commit' --sequence 0
$ fossil hook add --command "exit 1" --type 'before-commit' --sequence 1
$ fossil hook list
  0: type = before-commit
     command = echo '0xBADF00D'
     sequence = 0

  1: type = before-commit
     command = exit 1
     sequence = 1
$ fossil hook test 0
0xBADF00D
$ fossil hook test 1

Make a commit with --dry-run and --trace:

Expectation:

  • The output includes the string '0xBADF00D' because hook 0 was executed.
  • The output includes the trace log for both hooks.
  • The output reflects that the dry run commit failed due to hook 1 being executed and exiting with a non-zero code.

Reality:

$ fossil commit --dry-run --trace --comment 'Add test1.txt'
******* Commit Description *******
checkout /home/test_mctesterson/test/
repository /home/test_mctesterson/test/test.fossil
user test_mctesterson
branch trunk
tags trunk
ADDED      test1.txt
checkin-comment
Add test1.txt
***** End Commit Description *****
C Add\stest1.txt
D 2026-09-28T02:23:52.735
F test1.txt a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a
P 077e973c406b0ac33f2915e962d5531b059498dfe089decd264c236ec7af7cb5
R 2606381a2056697fd6fd8e24703f6cec
U test_mctesterson
Z ac3ce44124c67039bf7d302e58dd5467
New_Version: c15ff8d600f6de402e8852c8b628d37c1a95adbe49f955fb732b0a19765f75e9
stephan 2 weeks, 1 day ago

How I think it should work instead

To the best of my fallible knowledge, none of fossil's current developers uses the hooks capabilities. If that's indeed the case it's unlikely to be changed, but...

Patches would be thoughtfully considered.

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button