-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(performance): reduce the number of files scanned after merge conflict #946
feat(performance): reduce the number of files scanned after merge conflict #946
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #946 +/- ##
==========================================
+ Coverage 91.49% 91.54% +0.05%
==========================================
Files 178 178
Lines 7321 7372 +51
==========================================
+ Hits 6698 6749 +51
Misses 623 623
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
1d63a47
to
5fb03d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, your approach makes sense.
I am wondering if we always want this behavior or if it should be opt-in 🤔. What do you think?
One remark: calls to ls-files
and ls-tree
should use -z
to handle files with what git calls "unusual names" (*). An easy way to create an "unusual name" is to create one with a double quote in it.
(*): Other parts of ggshield would need to be fixed with regard to that too...
67ae7da
to
e33938f
Compare
ae9fca1
to
d95d1a6
Compare
d95d1a6
to
3e4b043
Compare
@agateau-gg I started doing something because it looked convenient in my tests and possibly useful but maybe you won't like it: I added an option to For example, But as it seems to fail on windows, I would like to check with you before debugging... 😓 |
The idea sounds good, but it should be in a separate commit or maybe even in a separate PR. |
fee9967
to
43c340f
Compare
629756b
to
29abeab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor remarks, but this is much easier to read!
29abeab
to
6dcb59a
Compare
changelog.d/20240819_162411_fnareoh_scrt_4759_optimize_files_to_scan_on_merge_commits.md
Show resolved
Hide resolved
6dcb59a
to
c3b3b62
Compare
Context
The goal of this Merge Request is to improve the speed of the ggshield pre-commit scan when commiting after a merge conflict.
What has been done
I created a script
gen_merge_commit.py
(temporarily added at the repository root) that creates a repo with two branches (master and feature_branch) a merge commit (with or without commit depending on the options) giving the following commit graph:I then experimented and with it:
- if MERGE_HEAD does not exists, we assume it is a regular commit and we should scan everything (current behavior)
- if MERGE_HEAD exists: we list the files about to be committed (git diff --staged --name-only), then compare the current shas of those files (using the command
git ls-files --staged <list_files_diff>
) with the shas of HEAD and MERGE_HEAD (obtained viagit ls-tree <list_files_diff>
), and if it differs from both, then the file has been modified and should be re-scanned...I'm opening this PR as a draft as it is clearly not ready (no proper automated testing) but the general idea should be reviewed...