mirror of
https://github.com/tiktok/sparo.git
synced 2024-11-27 01:26:07 -05:00
feat: improve necessary check for add fetch configs
This commit is contained in:
parent
16476655e4
commit
8879de5a9b
2 changed files with 11 additions and 5 deletions
|
@ -292,10 +292,16 @@ export class CheckoutCommand implements ICommand<ICheckoutCommandOptions> {
|
|||
});
|
||||
const remoteFetchGitConfig: string[] | undefined = result?.split('\n').filter(Boolean);
|
||||
|
||||
// Prevents adding the same remote branch multiple times
|
||||
const targetConfig: string = `+refs/heads/${branch}:refs/remotes/${remote}/${branch}`;
|
||||
if (remoteFetchGitConfig?.some((value: string) => value === targetConfig)) {
|
||||
return;
|
||||
if (remoteFetchGitConfig) {
|
||||
const targetConfig: string = `+refs/heads/${branch}:refs/remotes/${remote}/${branch}`;
|
||||
if (
|
||||
// Prevents adding remote branch if it is not single branch mode
|
||||
remoteFetchGitConfig.includes(`+refs/heads/*:refs/remotes/${remote}/*`) ||
|
||||
// Prevents adding the same remote branch multiple times
|
||||
remoteFetchGitConfig?.some((value: string) => value === targetConfig)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this._gitService.executeGitCommand({
|
||||
|
|
|
@ -68,7 +68,7 @@ export class FetchCommand implements ICommand<IFetchCommandOptions> {
|
|||
private _revertSingleBranchIfNecessary = (remote: string): (() => void) | undefined => {
|
||||
let remoteFetchGitConfig: string[] | undefined = this._getRemoteFetchGitConfig(remote);
|
||||
let callback: (() => void) | undefined;
|
||||
if (remoteFetchGitConfig) {
|
||||
if (remoteFetchGitConfig && !remoteFetchGitConfig.includes(`+refs/heads/*:refs/remotes/${remote}/*`)) {
|
||||
this._setAllBranchFetch(remote);
|
||||
|
||||
callback = () => {
|
||||
|
|
Loading…
Reference in a new issue