1
0
mirror of https://github.com/desktop/desktop synced 2024-06-30 22:54:41 +00:00
This commit is contained in:
Markus Olsson 2024-06-27 09:26:03 +02:00
parent 95f263a23d
commit c36ad79ecb
2 changed files with 43 additions and 8 deletions

34
app/src/lib/args.ts Normal file
View File

@ -0,0 +1,34 @@
export type ArgItem =
| string
| false
| undefined
| { [key: string]: string | boolean | undefined }
export type ArgTemplate = ArgItem | ReadonlyArray<ArgItem>
export const args = (...templates: ArgTemplate[]) => {
const arr = new Array<string>()
for (const template of templates) {
if (typeof template === 'string') {
arr.push(template)
} else if (template === false || template === undefined) {
continue
} else if (Array.isArray(template)) {
template.map(i => args(i)).forEach(i => arr.push(...i))
} else {
Object.entries(template).forEach(([key, value]) => {
if (value) {
arr.push(key)
// { '--progress': 'yes' } => ['--progress', 'yes']
// { '--progress': true } => ['--progress']
if (value !== true) {
arr.push(value)
}
}
})
}
}
return arr
}

View File

@ -13,21 +13,22 @@ import { enableRecurseSubmodulesFlag } from '../feature-flag'
import { IRemote } from '../../models/remote'
import { envForRemoteOperation } from './environment'
import { getConfigValue } from './config'
import { args } from '../args'
async function getPullArgs(
repository: Repository,
remote: string,
progressCallback?: (progress: IPullProgress) => void
) {
return [
...gitNetworkArguments(),
...gitRebaseArguments(),
args(
gitNetworkArguments(),
gitRebaseArguments(),
'pull',
...(await getDefaultPullDivergentBranchArguments(repository)),
...(enableRecurseSubmodulesFlag() ? ['--recurse-submodules'] : []),
...(progressCallback ? ['--progress'] : []),
remote,
]
await getDefaultPullDivergentBranchArguments(repository),
{ '--recurse-submodules': enableRecurseSubmodulesFlag() },
{ '--progress': progressCallback !== undefined },
remote
)
}
/**