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
22 changes: 21 additions & 1 deletion tools/installer/modules/custom-module-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,27 @@ class CustomModuleManager {
stdio: ['ignore', 'pipe', 'pipe'],
});
} 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,
stdio: ['ignore', 'pipe', 'pipe'],
});
Expand Down
Loading