In --experimental, don't report git untracked files as skipped with --use-git-ignore#577
Conversation
--experimental, don't report git untracked files as skipped with --use-git-ignore--experimental, don't report git untracked files as skipped with --use-git-ignore
| let selected, skipped = Find_targets.get_target_fpaths conf target_roots in | ||
| selected |> List.sort Fpath.compare | ||
| let targets = Find_targets.get_target_fpaths conf target_roots in | ||
| targets.targets |> List.sort Fpath.compare |
There was a problem hiding this comment.
maybe targets.selected would be more clear?
There was a problem hiding this comment.
and would match targets.skipped
There was a problem hiding this comment.
I think you are right. I will change it to selected
5f90e1d to
06b8b42
Compare
06b8b42 to
44332d3
Compare
src/targeting/Find_targets.ml
Outdated
| (* TODO: The 'git_repo' fields is needed to print out a warning to the *) | ||
| (* user, because some files in a git repo can be ignored. When multiple *) | ||
| (* roots are specified, we display this warning to the user when *) | ||
| (* at least one root is a git repo. Should we be more precise and *) | ||
| (* display which roots are git repos? *) |
There was a problem hiding this comment.
Comments are like this everywhere:
(*
*
*
*)But here each line is a comment.
There was a problem hiding this comment.
git_repo field (not fields)
There was a problem hiding this comment.
Comments are like this everywhere
Yeah, a setting somehow changed in my editor, and I keep forgetting to fix it....
src/targeting/Find_targets.ml
Outdated
| (fun (t, s, gr) root -> | ||
| let t', s', gr' = get_targets_for_project conf root in | ||
| Fppath_set.union t t', s' @ s, gr || gr') |
There was a problem hiding this comment.
I would rename these variables (t, s, gr) to something that's immediately clear.
src/targeting/Find_targets.ml
Outdated
| skipped_targets | ||
| in | ||
| (selected_targets, skipped_targets) | ||
| (selected_targets, skipped_targets, is_git_repo) |
There was a problem hiding this comment.
But we have a record type now, can we not reuse?
| @@ -52,9 +51,7 @@ let pp_summary ~respect_gitignore ~(maturity : Maturity.t) ~max_target_bytes | |||
| targets_not_in_git += 1 | |||
| continue | |||
| if targets_not_in_git != dir_targets: *) | |||
| Some "Scan was limited to files tracked by git." | |||
| else None | |||
| in | |||
| Fmt.pf ppf "Scan was limited to files tracked by git.@\n"; | |||
There was a problem hiding this comment.
Indentation of nested comment block.
dimitris-m
left a comment
There was a problem hiding this comment.
Left some comments that are easy to address.
Question:
Are there already tests for the case where is_git_repo = false and there are skipped files (non-git repo with actual skips)?
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [opengrep/opengrep](https://github.com/opengrep/opengrep) | patch | `v1.16.0` → `v1.16.1` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>opengrep/opengrep (opengrep/opengrep)</summary> ### [`v1.16.1`](https://github.com/opengrep/opengrep/releases/tag/v1.16.1): Opengrep 1.16.1 [Compare Source](opengrep/opengrep@v1.16.0...v1.16.1) #### Improvements - Pin Nuitka to 2.8.9 across all build workflows by [@​dimitris-m](https://github.com/dimitris-m) in [#​594](opengrep/opengrep#594) - Remove redundant pip and Nuitka dependencies by [@​dimitris-m](https://github.com/dimitris-m) in [#​573](opengrep/opengrep#573) - Support split rule/target directories in test subcommand by [@​qkaiser](https://github.com/qkaiser) in [#​576](opengrep/opengrep#576) #### Benchmarking - New benchmarking using hyperfine by [@​dimitris-m](https://github.com/dimitris-m) in [#​557](opengrep/opengrep#557) and [#​579](opengrep/opengrep#579) #### Bug fixes - Allow multiple logical operators in metavariable comparison by [@​maciejpirog](https://github.com/maciejpirog) in [#​590](opengrep/opengrep#590) - In `--experimental`, don't report git untracked files as skipped with `--use-git-ignore` by [@​maciejpirog](https://github.com/maciejpirog) in [#​577](opengrep/opengrep#577) - C#: Add primary constructor arguments to base class by [@​maciejpirog](https://github.com/maciejpirog) in [#​589](opengrep/opengrep#589) - Dockerfile: Add missing buildkit constructs by [@​maciejpirog](https://github.com/maciejpirog) in [#​581](opengrep/opengrep#581) - Dockerfile: Fix CRLF and comment-in-continuation parsing by [@​abezdina](https://github.com/abezdina) in [#​586](opengrep/opengrep#586) - Rust: Fix taint propagation through variable shadowing by [@​dimitris-m](https://github.com/dimitris-m) in [#​572](opengrep/opengrep#572) - TS/TSX: Add support for the `satisfies` construct by [@​maciejpirog](https://github.com/maciejpirog) in [#​592](opengrep/opengrep#592) #### Installation - Add Windows install script (pwsh) by [@​dimitris-m](https://github.com/dimitris-m) in [#​569](opengrep/opengrep#569) - Ensure that install.ps1 works on ARM by [@​dimitris-m](https://github.com/dimitris-m) in [#​571](opengrep/opengrep#571) - Fix: handle unparseable cosign version in install.sh by [@​dimitris-m](https://github.com/dimitris-m) in [#​580](opengrep/opengrep#580) #### Documentation - Improve the README by [@​dimitris-m](https://github.com/dimitris-m) in [#​570](opengrep/opengrep#570) #### New Contributors - [@​qkaiser](https://github.com/qkaiser) made their first contribution in [#​576](opengrep/opengrep#576) - [@​abezdina](https://github.com/abezdina) made their first contribution in [#​586](opengrep/opengrep#586) **Full Changelog**: <opengrep/opengrep@v1.16.0...v1.16.1> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNC4yIiwidXBkYXRlZEluVmVyIjoiNDMuMjQuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
Closes #575
Before, when run
--experimentalwith--use-git-ignore(default), we always reported that some files were skipped. This was counterintuitive, because it didn't mean that any files were actually skipped.Now, if the flag is set and the scanned root (more precisely, at least one of the scanned roots) is a git repo, we print the message
Scan was limited to files tracked by gitseparate from theSome files were skipped or only partially analyzedmessage. This way, when the user sees the latter, it means that there were actually files skipped for a reason (different than not being tracked by git).Example when both messages appear:
Example of a scan of a git repo when no files tracked by git are actually skipped:
Example of a scan of a root that is not a git repo, but there are files skipped: