This commit is contained in:
Jérôme Revillard 2026-04-29 14:02:26 +00:00 committed by GitHub
commit 358e1d8575
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 1 deletions

View File

@ -424,7 +424,27 @@ class CustomModuleManager {
stdio: ['ignore', 'pipe', 'pipe'], stdio: ['ignore', 'pipe', 'pipe'],
}); });
} else { } else {
execSync('git reset --hard origin/HEAD', { // Resolve the default branch (origin/HEAD) and fetch it explicitly.
// With shallow clones, `origin/HEAD` is stale and `git reset --hard
// origin/HEAD` never picks up new commits on the default branch.
let defaultBranch = 'main';
try {
defaultBranch = execSync('git symbolic-ref refs/remotes/origin/HEAD --short', {
cwd: repoCacheDir,
stdio: 'pipe',
})
.toString()
.trim()
.replace('origin/', '');
} catch {
// Fallback if origin/HEAD is not set
}
execSync(`git fetch --depth 1 origin ${quoteCustomRef(defaultBranch)}`, {
cwd: repoCacheDir,
stdio: ['ignore', 'pipe', 'pipe'],
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
});
execSync(`git reset --hard origin/${quoteCustomRef(defaultBranch)}`, {
cwd: repoCacheDir, cwd: repoCacheDir,
stdio: ['ignore', 'pipe', 'pipe'], stdio: ['ignore', 'pipe', 'pipe'],
}); });