-
Notifications
You must be signed in to change notification settings - Fork 323
🪞 9947 - Fix GitClientTest.test git diff when diff.noprefix=true is used #10299
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
Conversation
When diff.noprefix=true (or other git diff parameters that change
the prefix format) used, it changes the output from "git diff" and
and the test failure below is seen in GitClientTest.test git diff.
I have used this git setting in my ~/.gitconfig file for years as
it makes copying and pasting file names simpler.
java.lang.IllegalStateException: Line @@ -26 +26 @@ namespace Datadog.Trace.Logging contains changed lines information, but no changed file info is available
at datadog.trace.civisibility.git.tree.GitDiffParser.parse(GitDiffParser.java:48)
at datadog.trace.civisibility.utils.ShellCommandExecutor.executeCommand(ShellCommandExecutor.java:153)
at datadog.trace.civisibility.utils.ShellCommandExecutor.executeCommand(ShellCommandExecutor.java:57)
at datadog.trace.civisibility.git.tree.ShellGitClient.lambda$getGitDiff$18(ShellGitClient.java:926)
at datadog.trace.civisibility.git.tree.ShellGitClient.executeCommand(ShellGitClient.java:980)
at datadog.trace.civisibility.git.tree.ShellGitClient.getGitDiff(ShellGitClient.java:923)
at datadog.trace.civisibility.git.tree.GitClientTest.test git diff(GitClientTest.groovy:264)
Setting diff.noprefix=true changes the file name pattern and it
fails to match GitDiffParser.CHANGED_FILE_PATTERN.
$ git diff | grep ^diff
diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/tree/ShellGitClient.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/tree/ShellGitClient.java
$ GIT_CONFIG_PARAMETERS="'diff.noprefix=true'" git diff | grep ^diff
diff --git dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/tree/ShellGitClient.java dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/tree/ShellGitClient.java
Notice the lack of "a/" and "b/" on the latter output, but you'll see
that the pattern expects that:
private static final Pattern CHANGED_FILE_PATTERN =
Pattern.compile("^diff --git a/(?<oldfilename>.+) b/(?<newfilename>.+)$");
The simple workaround is to pass "--default-prefix" to "git diff",
however this option has only been present since 2023:
git/git@b39a569
A safer option would be to use "--no-prefix", which has existed since
2007:
git/git@eab9a40
This adds "--no-prefix", updates the regex, and adjusts test files.
Test Environment - sbt-scalatestJob Status: success
|
Test Environment - nebula-release-pluginJob Status: success
|
Test Environment - reactive-streams-jvmJob Status: success
|
Test Environment - netflix-zuulJob Status: success
|
Test Environment - pass4sJob Status: success
|
Test Environment - sonar-kotlinJob Status: success
|
Test Environment - jolokiaJob Status: success
|
Test Environment - okhttpJob Status: success
|
Test Environment - spring_bootJob Status: success
|
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 58 metrics, 7 unstable metrics. Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.59.0-SNAPSHOT~d4ad206b34, baseline=1.59.0-SNAPSHOT~92c84e28db
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.084 s) : 0, 1083533
Total [baseline] (8.767 s) : 0, 8767112
Agent [candidate] (1.089 s) : 0, 1089343
Total [candidate] (8.741 s) : 0, 8741404
section iast
Agent [baseline] (1.223 s) : 0, 1223430
Total [baseline] (9.282 s) : 0, 9281925
Agent [candidate] (1.23 s) : 0, 1229637
Total [candidate] (9.324 s) : 0, 9323738
gantt
title insecure-bank - break down per module: candidate=1.59.0-SNAPSHOT~d4ad206b34, baseline=1.59.0-SNAPSHOT~92c84e28db
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.187 ms) : 0, 1187
crashtracking [candidate] (1.191 ms) : 0, 1191
BytebuddyAgent [baseline] (650.923 ms) : 0, 650923
BytebuddyAgent [candidate] (654.877 ms) : 0, 654877
GlobalTracer [baseline] (282.469 ms) : 0, 282469
GlobalTracer [candidate] (283.789 ms) : 0, 283789
AppSec [baseline] (32.742 ms) : 0, 32742
AppSec [candidate] (32.828 ms) : 0, 32828
Debugger [baseline] (67.409 ms) : 0, 67409
Debugger [candidate] (67.685 ms) : 0, 67685
Remote Config [baseline] (635.509 µs) : 0, 636
Remote Config [candidate] (630.557 µs) : 0, 631
Telemetry [baseline] (8.94 ms) : 0, 8940
Telemetry [candidate] (8.949 ms) : 0, 8949
Flare Poller [baseline] (3.76 ms) : 0, 3760
Flare Poller [candidate] (3.749 ms) : 0, 3749
section iast
crashtracking [baseline] (1.184 ms) : 0, 1184
crashtracking [candidate] (1.184 ms) : 0, 1184
BytebuddyAgent [baseline] (791.786 ms) : 0, 791786
BytebuddyAgent [candidate] (796.484 ms) : 0, 796484
GlobalTracer [baseline] (255.859 ms) : 0, 255859
GlobalTracer [candidate] (257.219 ms) : 0, 257219
IAST [baseline] (26.949 ms) : 0, 26949
IAST [candidate] (27.286 ms) : 0, 27286
AppSec [baseline] (35.285 ms) : 0, 35285
AppSec [candidate] (34.588 ms) : 0, 34588
Debugger [baseline] (64.195 ms) : 0, 64195
Debugger [candidate] (64.672 ms) : 0, 64672
Remote Config [baseline] (593.094 µs) : 0, 593
Remote Config [candidate] (587.443 µs) : 0, 587
Telemetry [baseline] (8.513 ms) : 0, 8513
Telemetry [candidate] (8.496 ms) : 0, 8496
Flare Poller [baseline] (3.615 ms) : 0, 3615
Flare Poller [candidate] (3.547 ms) : 0, 3547
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.59.0-SNAPSHOT~d4ad206b34, baseline=1.59.0-SNAPSHOT~92c84e28db
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.094 s) : 0, 1093731
Total [baseline] (10.792 s) : 0, 10792281
Agent [candidate] (1.085 s) : 0, 1084611
Total [candidate] (10.781 s) : 0, 10780762
section appsec
Agent [baseline] (1.264 s) : 0, 1264310
Total [baseline] (10.854 s) : 0, 10854144
Agent [candidate] (1.264 s) : 0, 1263876
Total [candidate] (10.946 s) : 0, 10946478
section iast
Agent [baseline] (1.233 s) : 0, 1232551
Total [baseline] (11.208 s) : 0, 11207932
Agent [candidate] (1.225 s) : 0, 1224908
Total [candidate] (11.108 s) : 0, 11107566
section profiling
Agent [baseline] (1.206 s) : 0, 1206389
Total [baseline] (10.938 s) : 0, 10938471
Agent [candidate] (1.202 s) : 0, 1202273
Total [candidate] (10.942 s) : 0, 10941909
gantt
title petclinic - break down per module: candidate=1.59.0-SNAPSHOT~d4ad206b34, baseline=1.59.0-SNAPSHOT~92c84e28db
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.195 ms) : 0, 1195
crashtracking [candidate] (1.178 ms) : 0, 1178
BytebuddyAgent [baseline] (657.983 ms) : 0, 657983
BytebuddyAgent [candidate] (651.252 ms) : 0, 651252
GlobalTracer [baseline] (283.735 ms) : 0, 283735
GlobalTracer [candidate] (282.472 ms) : 0, 282472
AppSec [baseline] (32.875 ms) : 0, 32875
AppSec [candidate] (32.629 ms) : 0, 32629
Debugger [baseline] (68.788 ms) : 0, 68788
Debugger [candidate] (68.25 ms) : 0, 68250
Remote Config [baseline] (614.253 µs) : 0, 614
Remote Config [candidate] (612.87 µs) : 0, 613
Telemetry [baseline] (8.978 ms) : 0, 8978
Telemetry [candidate] (8.976 ms) : 0, 8976
Flare Poller [baseline] (3.775 ms) : 0, 3775
Flare Poller [candidate] (3.745 ms) : 0, 3745
section appsec
crashtracking [baseline] (1.189 ms) : 0, 1189
crashtracking [candidate] (1.187 ms) : 0, 1187
BytebuddyAgent [baseline] (691.062 ms) : 0, 691062
BytebuddyAgent [candidate] (690.56 ms) : 0, 690560
GlobalTracer [baseline] (258.137 ms) : 0, 258137
GlobalTracer [candidate] (257.802 ms) : 0, 257802
IAST [baseline] (24.572 ms) : 0, 24572
IAST [candidate] (24.519 ms) : 0, 24519
AppSec [baseline] (173.917 ms) : 0, 173917
AppSec [candidate] (173.111 ms) : 0, 173111
Debugger [baseline] (66.305 ms) : 0, 66305
Debugger [candidate] (67.382 ms) : 0, 67382
Remote Config [baseline] (765.466 µs) : 0, 765
Remote Config [candidate] (757.207 µs) : 0, 757
Telemetry [baseline] (9.231 ms) : 0, 9231
Telemetry [candidate] (9.425 ms) : 0, 9425
Flare Poller [baseline] (3.736 ms) : 0, 3736
Flare Poller [candidate] (3.751 ms) : 0, 3751
section iast
crashtracking [baseline] (1.189 ms) : 0, 1189
crashtracking [candidate] (1.191 ms) : 0, 1191
BytebuddyAgent [baseline] (796.937 ms) : 0, 796937
BytebuddyAgent [candidate] (792.518 ms) : 0, 792518
GlobalTracer [baseline] (257.704 ms) : 0, 257704
GlobalTracer [candidate] (255.987 ms) : 0, 255987
IAST [baseline] (27.257 ms) : 0, 27257
IAST [candidate] (26.984 ms) : 0, 26984
AppSec [baseline] (34.707 ms) : 0, 34707
AppSec [candidate] (31.598 ms) : 0, 31598
Debugger [baseline] (66.313 ms) : 0, 66313
Debugger [candidate] (68.688 ms) : 0, 68688
Remote Config [baseline] (584.382 µs) : 0, 584
Remote Config [candidate] (563.198 µs) : 0, 563
Telemetry [baseline] (8.636 ms) : 0, 8636
Telemetry [candidate] (8.373 ms) : 0, 8373
Flare Poller [baseline] (3.678 ms) : 0, 3678
Flare Poller [candidate] (3.537 ms) : 0, 3537
section profiling
crashtracking [baseline] (1.218 ms) : 0, 1218
crashtracking [candidate] (1.215 ms) : 0, 1215
BytebuddyAgent [baseline] (703.684 ms) : 0, 703684
BytebuddyAgent [candidate] (701.865 ms) : 0, 701865
GlobalTracer [baseline] (221.432 ms) : 0, 221432
GlobalTracer [candidate] (220.246 ms) : 0, 220246
AppSec [baseline] (32.324 ms) : 0, 32324
AppSec [candidate] (32.093 ms) : 0, 32093
Debugger [baseline] (68.254 ms) : 0, 68254
Debugger [candidate] (67.661 ms) : 0, 67661
Remote Config [baseline] (629.289 µs) : 0, 629
Remote Config [candidate] (645.428 µs) : 0, 645
Telemetry [baseline] (8.776 ms) : 0, 8776
Telemetry [candidate] (8.677 ms) : 0, 8677
Flare Poller [baseline] (3.711 ms) : 0, 3711
Flare Poller [candidate] (3.628 ms) : 0, 3628
ProfilingAgent [baseline] (96.353 ms) : 0, 96353
ProfilingAgent [candidate] (96.459 ms) : 0, 96459
Profiling [baseline] (96.932 ms) : 0, 96932
Profiling [candidate] (97.041 ms) : 0, 97041
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 4 performance regressions! Performance is the same for 16 metrics, 16 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.59.0-SNAPSHOT~d4ad206b34, baseline=1.59.0-SNAPSHOT~92c84e28db
dateFormat X
axisFormat %s
section baseline
no_agent (18.38 ms) : 18185, 18576
. : milestone, 18380,
appsec (18.803 ms) : 18613, 18993
. : milestone, 18803,
code_origins (17.746 ms) : 17571, 17921
. : milestone, 17746,
iast (17.423 ms) : 17250, 17596
. : milestone, 17423,
profiling (18.461 ms) : 18276, 18645
. : milestone, 18461,
tracing (17.684 ms) : 17508, 17859
. : milestone, 17684,
section candidate
no_agent (19.378 ms) : 19179, 19576
. : milestone, 19378,
appsec (19.72 ms) : 19517, 19923
. : milestone, 19720,
code_origins (17.577 ms) : 17403, 17750
. : milestone, 17577,
iast (17.999 ms) : 17819, 18180
. : milestone, 17999,
profiling (18.459 ms) : 18274, 18644
. : milestone, 18459,
tracing (18.512 ms) : 18326, 18699
. : milestone, 18512,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.59.0-SNAPSHOT~d4ad206b34, baseline=1.59.0-SNAPSHOT~92c84e28db
dateFormat X
axisFormat %s
section baseline
no_agent (1.193 ms) : 1181, 1205
. : milestone, 1193,
iast (3.191 ms) : 3148, 3233
. : milestone, 3191,
iast_FULL (5.606 ms) : 5551, 5661
. : milestone, 5606,
iast_GLOBAL (3.557 ms) : 3505, 3609
. : milestone, 3557,
profiling (1.933 ms) : 1916, 1950
. : milestone, 1933,
tracing (1.774 ms) : 1760, 1788
. : milestone, 1774,
section candidate
no_agent (1.189 ms) : 1177, 1200
. : milestone, 1189,
iast (3.249 ms) : 3208, 3290
. : milestone, 3249,
iast_FULL (5.821 ms) : 5763, 5879
. : milestone, 5821,
iast_GLOBAL (3.675 ms) : 3619, 3730
. : milestone, 3675,
profiling (1.99 ms) : 1972, 2007
. : milestone, 1990,
tracing (1.81 ms) : 1795, 1825
. : milestone, 1810,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 1 unstable metrics. Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.59.0-SNAPSHOT~d4ad206b34, baseline=1.59.0-SNAPSHOT~92c84e28db
dateFormat X
axisFormat %s
section baseline
no_agent (1.483 ms) : 1472, 1495
. : milestone, 1483,
appsec (3.701 ms) : 3480, 3922
. : milestone, 3701,
iast (2.217 ms) : 2152, 2282
. : milestone, 2217,
iast_GLOBAL (2.253 ms) : 2189, 2318
. : milestone, 2253,
profiling (2.102 ms) : 2047, 2156
. : milestone, 2102,
tracing (2.052 ms) : 2001, 2103
. : milestone, 2052,
section candidate
no_agent (1.477 ms) : 1466, 1489
. : milestone, 1477,
appsec (3.673 ms) : 3458, 3888
. : milestone, 3673,
iast (2.224 ms) : 2159, 2289
. : milestone, 2224,
iast_GLOBAL (2.257 ms) : 2192, 2322
. : milestone, 2257,
profiling (2.058 ms) : 2006, 2110
. : milestone, 2058,
tracing (2.053 ms) : 2002, 2105
. : milestone, 2053,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.59.0-SNAPSHOT~d4ad206b34, baseline=1.59.0-SNAPSHOT~92c84e28db
dateFormat X
axisFormat %s
section baseline
no_agent (15.581 s) : 15581000, 15581000
. : milestone, 15581000,
appsec (14.517 s) : 14517000, 14517000
. : milestone, 14517000,
iast (18.164 s) : 18164000, 18164000
. : milestone, 18164000,
iast_GLOBAL (17.962 s) : 17962000, 17962000
. : milestone, 17962000,
profiling (14.951 s) : 14951000, 14951000
. : milestone, 14951000,
tracing (14.481 s) : 14481000, 14481000
. : milestone, 14481000,
section candidate
no_agent (14.992 s) : 14992000, 14992000
. : milestone, 14992000,
appsec (14.463 s) : 14463000, 14463000
. : milestone, 14463000,
iast (18.034 s) : 18034000, 18034000
. : milestone, 18034000,
iast_GLOBAL (17.893 s) : 17893000, 17893000
. : milestone, 17893000,
profiling (14.978 s) : 14978000, 14978000
. : milestone, 14978000,
tracing (14.763 s) : 14763000, 14763000
. : milestone, 14763000,
|
Test Environment - sonar-javaJob Status: success
|
daniel-mohedano
left a comment
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.
LGTM from Test Optimization side 👍
This PR mirrors the changes from the original community contribution to enable CI testing with maintainer privileges.
Original PR: #9947
Original Author: @deejgregor
Original Branch: deejgregor/dd-trace-java:fix-git-client-test-with-diff-noprefix
Closes #9947
This is an automated mirror created to run CI checks. See tooling/mirror-community-pull-request.sh for details.