Skip to content

Commit

Permalink
fix: command failed git config #73
Browse files Browse the repository at this point in the history
gitoepn config in git config is new feature, when user upgrade gitpen but without gitconfig,
will throw error.
  • Loading branch information
hotoo committed Apr 28, 2019
1 parent a7e67b4 commit 34fe595
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions bin/openrc.js
Expand Up @@ -56,28 +56,32 @@ function openrc(uri, options) {
var cwd = options.cwd || process.cwd();

// parse config from global .gitconfig
child_process.execSync(
'git config --list --global | grep "^gitopen\\.' + HOSTNAME.replace(/\./g, '\\.') + '\\."',
{cwd: cwd}
).toString().trim().split(/\r\n|\r|\n/).forEach(item => {
var kv = item.split('=');
if (kv.length < 2) { return; }
var key = kv.shift().trim().replace('gitopen.' + HOSTNAME + '.', '');
var val = kv.join('=').trim();
gitConfig[key] = val;
});
try {
child_process.execSync(
'git config --list --global | grep "^gitopen\\.' + HOSTNAME.replace(/\./g, '\\.') + '\\."',
{cwd: cwd}
).toString().trim().split(/\r\n|\r|\n/).forEach(item => {
var kv = item.split('=');
if (kv.length < 2) { return; }
var key = kv.shift().trim().replace('gitopen.' + HOSTNAME + '.', '');
var val = kv.join('=').trim();
gitConfig[key] = val;
});
} catch (ex) { /* */ }

// parse config from local repo .gitconfig
child_process.execSync(
'git config --list --local | grep "^gitopen\\."',
{cwd: cwd}
).toString().trim().split(/\r\n|\r|\n/).forEach(item => {
var kv = item.split('=');
if (kv.length < 2) { return; }
var key = kv.shift().trim().replace(/^gitopen\./, '');
var val = kv.join('=').trim();
gitConfig[key] = val;
});
try {
child_process.execSync(
'git config --list --local | grep "^gitopen\\."',
{cwd: cwd}
).toString().trim().split(/\r\n|\r|\n/).forEach(item => {
var kv = item.split('=');
if (kv.length < 2) { return; }
var key = kv.shift().trim().replace(/^gitopen\./, '');
var val = kv.join('=').trim();
gitConfig[key] = val;
});
} catch (ex) { /* */ }

// 当 .gitopenrc 中定义为 type=custom,.gitconfig 中定义 type!=custom 时,
// 将 schema 改回 .gitconfig 中定义的 scheme 配置。
Expand Down

0 comments on commit 34fe595

Please sign in to comment.