1
0
mirror of https://github.com/desktop/desktop synced 2024-06-30 22:54:41 +00:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Markus Olsson
d2c6ddb164
Merge pull request #18887 from desktop/args-args-everywhere
Inline argument conditionals
2024-06-27 09:27:16 +02:00
Markus Olsson
95f263a23d Set --progress and --recurse-submodules inline when necessary 2024-06-24 13:44:30 +02:00
Markus Olsson
10c3d47706 Set --progress and --recurse-submodules inline when necessary 2024-06-24 13:44:13 +02:00
Markus Olsson
8d86091ae3 🎨 Easier to read this way IMO 2024-06-24 13:43:48 +02:00
Markus Olsson
d8873cb08d Add --recurse-submodules and --progress inline when necessary 2024-06-24 13:43:14 +02:00
Markus Olsson
a404a3f251 Add --progress inline when necesary 2024-06-24 13:40:51 +02:00
4 changed files with 29 additions and 61 deletions

View File

@ -20,28 +20,22 @@ import { IRemote } from '../../models/remote'
export type ProgressCallback = (progress: ICheckoutProgress) => void
function getCheckoutArgs(progressCallback?: ProgressCallback) {
return progressCallback != null
? [...gitNetworkArguments(), 'checkout', '--progress']
: [...gitNetworkArguments(), 'checkout']
return [
...gitNetworkArguments(),
'checkout',
...(progressCallback ? ['--progress'] : []),
]
}
async function getBranchCheckoutArgs(branch: Branch) {
const baseArgs: ReadonlyArray<string> = []
if (enableRecurseSubmodulesFlag()) {
return branch.type === BranchType.Remote
? baseArgs.concat(
branch.name,
'-b',
branch.nameWithoutRemote,
'--recurse-submodules',
'--'
)
: baseArgs.concat(branch.name, '--recurse-submodules', '--')
}
return branch.type === BranchType.Remote
? baseArgs.concat(branch.name, '-b', branch.nameWithoutRemote, '--')
: baseArgs.concat(branch.name, '--')
return [
branch.name,
...(branch.type === BranchType.Remote
? ['-b', branch.nameWithoutRemote]
: []),
...(enableRecurseSubmodulesFlag() ? ['--recurse-submodules'] : []),
'--',
]
}
async function getCheckoutOpts(

View File

@ -485,8 +485,7 @@ export function gitRebaseArguments() {
// uses the merge backend even if the user has the apply backend
// configured, since this is the only one supported.
// This can go away once git deprecates the apply backend.
'-c',
'rebase.backend=merge',
...['-c', 'rebase.backend=merge'],
]
}

View File

@ -11,28 +11,16 @@ async function getFetchArgs(
remote: string,
progressCallback?: (progress: IFetchProgress) => void
) {
if (enableRecurseSubmodulesFlag()) {
return progressCallback != null
? [
...gitNetworkArguments(),
'fetch',
'--progress',
'--prune',
'--recurse-submodules=on-demand',
remote,
]
: [
...gitNetworkArguments(),
'fetch',
'--prune',
'--recurse-submodules=on-demand',
remote,
]
} else {
return progressCallback != null
? [...gitNetworkArguments(), 'fetch', '--progress', '--prune', remote]
: [...gitNetworkArguments(), 'fetch', '--prune', remote]
}
return [
...gitNetworkArguments(),
'fetch',
...(progressCallback ? ['--progress'] : []),
'--prune',
...(enableRecurseSubmodulesFlag()
? ['--recurse-submodules=on-demand']
: []),
remote,
]
}
/**

View File

@ -19,28 +19,15 @@ async function getPullArgs(
remote: string,
progressCallback?: (progress: IPullProgress) => void
) {
const divergentPathArgs = await getDefaultPullDivergentBranchArguments(
repository
)
const args = [
return [
...gitNetworkArguments(),
...gitRebaseArguments(),
'pull',
...divergentPathArgs,
...(await getDefaultPullDivergentBranchArguments(repository)),
...(enableRecurseSubmodulesFlag() ? ['--recurse-submodules'] : []),
...(progressCallback ? ['--progress'] : []),
remote,
]
if (enableRecurseSubmodulesFlag()) {
args.push('--recurse-submodules')
}
if (progressCallback != null) {
args.push('--progress')
}
args.push(remote)
return args
}
/**