2021-08-10 03:00:29 -04:00
|
|
|
import * as exec from '@actions/exec';
|
2020-05-04 14:59:11 -04:00
|
|
|
|
|
|
|
const git = async (args: string[] = []): Promise<string> => {
|
2021-08-10 03:00:29 -04:00
|
|
|
return await exec
|
|
|
|
.getExecOutput(`git`, args, {
|
|
|
|
ignoreReturnCode: true,
|
|
|
|
silent: true
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
|
|
|
throw new Error(res.stderr);
|
|
|
|
}
|
|
|
|
return res.stdout.trim();
|
|
|
|
});
|
2020-05-04 14:59:11 -04:00
|
|
|
};
|
|
|
|
|
2021-08-10 03:28:13 -04:00
|
|
|
export async function setConfig(key: string, value: string, global: boolean): Promise<void> {
|
2022-03-15 02:56:21 -04:00
|
|
|
const args: Array<string> = ['config'];
|
2021-08-10 03:28:13 -04:00
|
|
|
if (global) {
|
|
|
|
args.push('--global');
|
|
|
|
}
|
|
|
|
args.push(key, value);
|
|
|
|
await git(args);
|
2020-05-05 14:01:45 -04:00
|
|
|
}
|