fix: only pre-fetch when branch prefix is a known remote name (#958)
* fix: only pre-fetch when branch prefix is a known remote name * fix(ui): avoid unused ProjectEntry import --------- Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Bohdan Triapitsyn
parent
bc6cb91954
commit
b1a96c7b36
@@ -1653,10 +1653,12 @@ export const GitView: React.FC = () => {
|
|||||||
|
|
||||||
const currentBranch = status?.current;
|
const currentBranch = status?.current;
|
||||||
|
|
||||||
|
const knownRemoteNames = new Set(effectiveRemotes.map((r) => r.name));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// If it's a remote branch (contains '/'), fetch latest first
|
// If it's a remote-tracking branch (prefix matches a known remote), fetch latest first
|
||||||
const slashIndex = branch.indexOf('/');
|
const slashIndex = branch.indexOf('/');
|
||||||
if (slashIndex > 0) {
|
if (slashIndex > 0 && knownRemoteNames.has(branch.substring(0, slashIndex))) {
|
||||||
const remote = branch.substring(0, slashIndex);
|
const remote = branch.substring(0, slashIndex);
|
||||||
const remoteBranch = branch.substring(slashIndex + 1);
|
const remoteBranch = branch.substring(slashIndex + 1);
|
||||||
addOperationLog(`Fetching ${remote}/${remoteBranch}...`, 'running');
|
addOperationLog(`Fetching ${remote}/${remoteBranch}...`, 'running');
|
||||||
@@ -1694,7 +1696,7 @@ export const GitView: React.FC = () => {
|
|||||||
}
|
}
|
||||||
// Note: branchOperation is cleared when dialog closes via handleOperationComplete
|
// Note: branchOperation is cleared when dialog closes via handleOperationComplete
|
||||||
},
|
},
|
||||||
[currentDirectory, git, status, refreshStatusAndBranches, refreshLog, isUncommittedChangesError, persistConflictState, clearConflictState, addOperationLog, updateLastLog, resetOperationLogs]
|
[currentDirectory, git, status, effectiveRemotes, refreshStatusAndBranches, refreshLog, isUncommittedChangesError, persistConflictState, clearConflictState, addOperationLog, updateLastLog, resetOperationLogs]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleRebase = React.useCallback(
|
const handleRebase = React.useCallback(
|
||||||
@@ -1705,10 +1707,12 @@ export const GitView: React.FC = () => {
|
|||||||
|
|
||||||
const currentBranch = status?.current;
|
const currentBranch = status?.current;
|
||||||
|
|
||||||
|
const knownRemoteNames = new Set(effectiveRemotes.map((r) => r.name));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// If it's a remote branch (contains '/'), fetch latest first
|
// If it's a remote-tracking branch (prefix matches a known remote), fetch latest first
|
||||||
const slashIndex = branch.indexOf('/');
|
const slashIndex = branch.indexOf('/');
|
||||||
if (slashIndex > 0) {
|
if (slashIndex > 0 && knownRemoteNames.has(branch.substring(0, slashIndex))) {
|
||||||
const remote = branch.substring(0, slashIndex);
|
const remote = branch.substring(0, slashIndex);
|
||||||
const remoteBranch = branch.substring(slashIndex + 1);
|
const remoteBranch = branch.substring(slashIndex + 1);
|
||||||
addOperationLog(`Fetching ${remote}/${remoteBranch}...`, 'running');
|
addOperationLog(`Fetching ${remote}/${remoteBranch}...`, 'running');
|
||||||
@@ -1746,7 +1750,7 @@ export const GitView: React.FC = () => {
|
|||||||
}
|
}
|
||||||
// Note: branchOperation is cleared when dialog closes via handleOperationComplete
|
// Note: branchOperation is cleared when dialog closes via handleOperationComplete
|
||||||
},
|
},
|
||||||
[currentDirectory, git, status, refreshStatusAndBranches, refreshLog, isUncommittedChangesError, persistConflictState, clearConflictState, addOperationLog, updateLastLog, resetOperationLogs]
|
[currentDirectory, git, status, effectiveRemotes, refreshStatusAndBranches, refreshLog, isUncommittedChangesError, persistConflictState, clearConflictState, addOperationLog, updateLastLog, resetOperationLogs]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleAbortConflict = React.useCallback(async () => {
|
const handleAbortConflict = React.useCallback(async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user