From 1fcfc7d1cfe96de019f40439601b0bd73be35928 Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Thu, 21 May 2026 12:13:44 +0200 Subject: [PATCH] feat: introduce early exit in repo unshallowing after first success --- .../civisibility/git/tree/GitRepoUnshallow.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/tree/GitRepoUnshallow.java b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/tree/GitRepoUnshallow.java index 489e2a4d377..855dd3c0b1a 100644 --- a/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/tree/GitRepoUnshallow.java +++ b/dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/git/tree/GitRepoUnshallow.java @@ -28,6 +28,10 @@ public synchronized boolean unshallow() long unshallowStart = System.currentTimeMillis(); try { gitClient.unshallow(GitClient.HEAD); + LOGGER.debug( + "Repository unshallowing via HEAD took {} ms", + System.currentTimeMillis() - unshallowStart); + return true; } catch (ShellCommandExecutor.ShellCommandFailedException e) { LOGGER.debug( "Could not unshallow using HEAD - assuming HEAD points to a local commit that does not exist in the remote repo", @@ -37,13 +41,20 @@ public synchronized boolean unshallow() try { String upstreamBranch = gitClient.getUpstreamBranchSha(); gitClient.unshallow(upstreamBranch); + LOGGER.debug( + "Repository unshallowing via upstream branch took {} ms", + System.currentTimeMillis() - unshallowStart); + return true; } catch (ShellCommandExecutor.ShellCommandFailedException e) { LOGGER.debug( "Could not unshallow using upstream branch - assuming currently checked out local branch does not track any remote branch", e); - gitClient.unshallow(null); } - LOGGER.debug("Repository unshallowing took {} ms", System.currentTimeMillis() - unshallowStart); + + gitClient.unshallow(null); + LOGGER.debug( + "Repository unshallowing via no-ref fetch took {} ms", + System.currentTimeMillis() - unshallowStart); return true; } }