mirror of
https://github.com/desktop/desktop
synced 2024-06-30 22:54:41 +00:00
wip
This commit is contained in:
parent
95f263a23d
commit
c36ad79ecb
34
app/src/lib/args.ts
Normal file
34
app/src/lib/args.ts
Normal 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
|
||||
}
|
|
@ -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
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user