2021-05-19 08:05:29 -06:00
|
|
|
import is from '@sindresorhus/is';
|
2022-01-27 04:22:48 -07:00
|
|
|
import type { SimpleGitOptions } from 'simple-git';
|
2022-04-17 11:12:42 -06:00
|
|
|
import { GlobalConfig } from '../../config/global';
|
2021-11-26 13:36:17 -07:00
|
|
|
import type { GitNoVerifyOption } from './types';
|
2021-05-19 08:05:29 -06:00
|
|
|
|
2021-11-26 13:36:17 -07:00
|
|
|
let noVerify: GitNoVerifyOption[] = ['push', 'commit'];
|
2021-05-19 08:05:29 -06:00
|
|
|
|
|
|
|
export function setNoVerify(value: GitNoVerifyOption[]): void {
|
2022-02-09 08:48:51 -07:00
|
|
|
// istanbul ignore if
|
2021-05-19 08:05:29 -06:00
|
|
|
if (!is.array(value, is.string)) {
|
|
|
|
throw new Error('config error: gitNoVerify should be an array of strings');
|
|
|
|
}
|
|
|
|
noVerify = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getNoVerify(): GitNoVerifyOption[] {
|
|
|
|
return noVerify;
|
|
|
|
}
|
2021-10-11 01:03:15 -06:00
|
|
|
|
|
|
|
export function simpleGitConfig(): Partial<SimpleGitOptions> {
|
2022-04-20 14:33:36 -06:00
|
|
|
const config: Partial<SimpleGitOptions> = {
|
2021-10-11 01:03:15 -06:00
|
|
|
completion: {
|
|
|
|
onClose: true,
|
|
|
|
onExit: false,
|
|
|
|
},
|
2022-11-17 23:59:08 -07:00
|
|
|
config: ['core.quotePath=false'],
|
2021-10-11 01:03:15 -06:00
|
|
|
};
|
2022-04-20 14:33:36 -06:00
|
|
|
// https://github.com/steveukx/git-js/pull/591
|
|
|
|
const gitTimeout = GlobalConfig.get('gitTimeout');
|
|
|
|
if (is.number(gitTimeout) && gitTimeout > 0) {
|
|
|
|
config.timeout = { block: gitTimeout };
|
|
|
|
}
|
|
|
|
return config;
|
2021-10-11 01:03:15 -06:00
|
|
|
}
|