({
fs: _fs,
dir,
gitdir = join(dir, '.git'),
path,
value,
append = false,
})
| 50 | * console.log(file) |
| 51 | */ |
| 52 | export async function setConfig({ |
| 53 | fs: _fs, |
| 54 | dir, |
| 55 | gitdir = join(dir, '.git'), |
| 56 | path, |
| 57 | value, |
| 58 | append = false, |
| 59 | }) { |
| 60 | try { |
| 61 | assertParameter('fs', _fs) |
| 62 | assertParameter('gitdir', gitdir) |
| 63 | assertParameter('path', path) |
| 64 | // assertParameter('value', value) // We actually allow 'undefined' as a value to unset/delete |
| 65 | |
| 66 | const fs = new FileSystem(_fs) |
| 67 | const updatedGitdir = await discoverGitdir({ fsp: fs, dotgit: gitdir }) |
| 68 | const config = await GitConfigManager.get({ fs, gitdir: updatedGitdir }) |
| 69 | if (append) { |
| 70 | await config.append(path, value) |
| 71 | } else { |
| 72 | await config.set(path, value) |
| 73 | } |
| 74 | await GitConfigManager.save({ fs, gitdir: updatedGitdir, config }) |
| 75 | } catch (err) { |
| 76 | err.caller = 'git.setConfig' |
| 77 | throw err |
| 78 | } |
| 79 | } |
searching dependent graphs…