Skip to content

Commit 2d6605f

Browse files
daniel-mohedanodevflow.devflow-routing-intake
andauthored
feat: check for DDCI legacy mode before running merge base (#10624)
feat: check for DDCI legacy mode before running merge base Merge branch 'master' into daniel.mohedano/ddci-legacy Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent d7515c8 commit 2d6605f

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/CiVisibilityRepoServices.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,15 @@ private static PullRequestInfo buildUserPullRequestInfo(
159159
String targetSha = environment.get(Constants.DDCI_PULL_REQUEST_TARGET_SHA);
160160
String sourceSha = environment.get(Constants.DDCI_PULL_REQUEST_SOURCE_SHA);
161161
String mergeBase = null;
162-
try {
163-
mergeBase = gitClient.getMergeBase(targetSha, sourceSha);
164-
} catch (Exception ignored) {
162+
163+
if (!Constants.DDCI_LEGACY_KIND.equals(environment.get(Constants.DDCI_REQUEST_KIND))) {
164+
// legacy mode doesn't set a valid target sha to compute the merge base
165+
try {
166+
mergeBase = gitClient.getMergeBase(targetSha, sourceSha);
167+
} catch (Exception ignored) {
168+
}
165169
}
170+
166171
PullRequestInfo ddCiInfo =
167172
new PullRequestInfo(
168173
null,

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/Constants.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,14 @@ public interface Constants {
2222
* the necessary data is not exposed by the CI provider
2323
*/
2424
String DDCI_PULL_REQUEST_TARGET_SHA = "DDCI_PULL_REQUEST_TARGET_SHA";
25+
26+
/**
27+
* Env var containing the DDCI mode used. When the legacy mode is used,
28+
* DDCI_PULL_REQUEST_TARGET_SHA won't contain the expected value, but the previous base on the
29+
* push event.
30+
*/
31+
String DDCI_REQUEST_KIND = "DDCI_REQUEST_KIND";
32+
33+
// Legacy mode identifier
34+
String DDCI_LEGACY_KIND = "REQUEST_KIND_LEGACY_REQUEST";
2535
}

0 commit comments

Comments
 (0)