Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid skipping the ref-populating fetch in detached checkouts

In detached shallow CI checkouts with no upstream branch, git fetch origin <HEAD sha> can succeed while leaving refs/remotes/<remote>/* empty; before this change the subsequent @{upstream} failure fell through to gitClient.unshallow(null), which runs a no-ref fetch and populates those remote-tracking refs. Returning here skips that path, so later PR diff/base detection in ShellGitClient.getBaseCommitSha/getBaseBranchCandidates can fail to find the base branch even though the repository was previously recoverable.

Useful? React with 👍 / 👎.

} 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",
Expand All @@ -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;
}
}
Loading