[go: up one dir, main page]

Does it commit failing tests ?

TL;DR history will contains commits with only passing tests (with a nominal usage)

Long story : Yes and no

Yes, it does a commit at every steps, including when tests are failing

And no, because it will amend the previous commit when :

  • gambling several times that the test fails
  • gambling that the pass after a gamble that the test fails

Commits with failing tests are temporary and should not ends up in the history

Example

Assuming every gambles were the good one, so everything is committed at each command

Doing the following commands :

git gamble --red      --message "first iteration red"
git gamble --red      --message "first iteration red edited" # improve the test
git gamble --green    --message "first iteration green"
git gamble --red      --message "second iteration red"
git gamble --green    --message "second iteration green"
git gamble --refactor --message "second iteration refactor"

Will end with this git history :

gitGraph TB:
    commit id:"initial commit"
    commit id:"first iteration green"
    commit id:"second iteration green"
    commit id:"second iteration refactor"

The full history will look like this :

---
config:
    theme: 'base'
---
gitGraph TB:
    commit id:"initial commit"
    branch GC_1
    commit id:"first iteration red" type:REVERSE
    switch main
    branch GC_2
    commit id:"first iteration red edited" type:REVERSE
    switch main
    commit id:"first iteration green"
    branch GC_3
    commit id:"second iteration red" type:REVERSE
    switch main
    commit id:"second iteration green"
    commit id:"second iteration refactor"

Note : the GC_* branches are just a representation of dangling commits that will eventually be deleted by the garbage collector

The garbage collector is an automatic mecanism in git, nothing special have to be done