Repository navigation
Conversation
75b2d6b to
f205b86
Compare
| Supposed to be used only with [`--git-diff-filter`](/guide/command-line-options.html#git-diff-filter) option. Configures the base branch for `git diff` command. | ||
| Sets the branch reference or commit SHA used with [`--git-diff-filter`](#git-diff-filter) or [`--git-diff-lines`](#git-diff-lines). | ||
|
|
||
| <span class="version-since">Automatic CI base selection: unreleased (after Infection 0.35.10)</span> |
| <span class="version-since">Automatic CI base selection: unreleased (after Infection 0.35.10)</span> | ||
|
|
||
| <!-- Preserve links to the removed Travis example. --> | ||
| <span id="Example-for-Travis-CI"></span> |
| - vendor/bin/infection --git-diff-lines #... | ||
| ``` | ||
|
|
||
| [](https://infection.github.io) |
There was a problem hiding this comment.
not sure why this was there but the link is broken and the badge is the next page so removed it
| | GitHub Actions, merge queue | `merge_group.base_sha` from the event payload at `GITHUB_EVENT_PATH` | | ||
| | GitLab CI, merge request | `CI_MERGE_REQUEST_DIFF_BASE_SHA`, including detached, merged results, and merge train pipelines | | ||
|
|
||
| When CI metadata does not provide a base, Infection resolves the local symbolic reference `refs/remotes/origin/HEAD`, which normally identifies `origin`'s default branch. If it cannot resolve that reference, it falls back to `origin/master`. A missing or unreadable GitHub event file, or invalid JSON, also causes Infection to use the repository default lookup. |
There was a problem hiding this comment.
| When CI metadata does not provide a base, Infection resolves the local symbolic reference `refs/remotes/origin/HEAD`, which normally identifies `origin`'s default branch. If it cannot resolve that reference, it falls back to `origin/master`. A missing or unreadable GitHub event file, or invalid JSON, also causes Infection to use the repository default lookup. | |
| When CI metadata does not provide a base, Infection resolves the local symbolic reference `refs/remotes/origin/HEAD`, which normally identifies `origin`'s default branch. If it cannot resolve that reference, it falls back to `origin/main`. A missing or unreadable GitHub event file, or invalid JSON, also causes Infection to use the repository default lookup. |
I think main is the current default branch name.
There was a problem hiding this comment.
it is... but not in our code... Maybe worth changing that now though as it is the default for any new project for a few years already.
|
|
||
| When CI metadata does not provide a base, Infection resolves the local symbolic reference `refs/remotes/origin/HEAD`, which normally identifies `origin`'s default branch. If it cannot resolve that reference, it falls back to `origin/master`. A missing or unreadable GitHub event file, or invalid JSON, also causes Infection to use the repository default lookup. | ||
|
|
||
| Infection finds the merge base of the supplied reference and `HEAD`, then compares the checked-out files with that ancestor. This excludes changes made only on the target branch since the branches diverged. Both commits and enough history to find their common ancestor must be available locally. If Git cannot find a merge base, Infection falls back to a direct diff against the supplied reference, which can include changes outside the pull request. |
There was a problem hiding this comment.
Sounds like this explains what Git does by default, or what do I miss?
There was a problem hiding this comment.
we're explaining that we're doing git diff indeed, but as noted here, there are a few subtleties for it to work, 1) getting the right base and 2) having the necessary git history
| git fetch --depth=1 origin $GITHUB_BASE_REF | ||
|
|
||
| infection.phar --logger-github --git-diff-filter=A | ||
| infection.phar --logger-github=true --git-diff-filter=A |
There was a problem hiding this comment.
hmm I didn't add it in "using with CI" because I thought it was enabled automatically, it is not, so I should add it there and likewise for GitLab.
There was a problem hiding this comment.
no it is actually equivalent in this case so I suppose I should not change it more than necessary.
--logger-github: will autodetect whether should be enabled
--logger-github=true: force the reporter, even if not actually on GA
--logger-github=false: disables it
| git fetch --depth=1 origin $GITHUB_BASE_REF | ||
|
|
||
| infection.phar --logger-github --git-diff-filter=A | ||
| infection.phar --logger-github=true --git-diff-filter=A |
There was a problem hiding this comment.
actually I notice here we've been using the PHAR form so I should update the other examples added to use it too.
🤖 Disclaimer: the content of the PR has been generated entirely with Codex.
Document the changes from: