Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de60ea6

Browse files
authored
Merge branch 'master' into greenkeeper/electron-devtools-installer-2.2.4
2 parents 6bcbe9e + 6a79cd7 commit de60ea6

10 files changed

+785
-676
lines changed

bin/git-credential-atom.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async function fromKeytar(query) {
257257

258258
// Always remember credentials we had to go to GraphQL to get
259259
await new Promise((resolve, reject) => {
260-
fs.writeFile(rememberFile, err => {
260+
fs.writeFile(rememberFile, '', {encoding: 'utf8'}, err => {
261261
if (err) { reject(err); } else { resolve(); }
262262
});
263263
});
@@ -292,7 +292,7 @@ function dialog(query) {
292292
log('requesting dialog through Atom socket');
293293
log(`prompt = "${prompt}" includeUsername = ${includeUsername}`);
294294

295-
const socket = net.connect(sockPath, () => {
295+
const socket = net.connect(sockPath, async () => {
296296
log('connection established');
297297

298298
const parts = [];
@@ -320,7 +320,7 @@ function dialog(query) {
320320
};
321321

322322
if (reply.remember) {
323-
fs.writeFile(rememberFile, writeReply);
323+
fs.writeFile(rememberFile, '', {encoding: 'utf8'}, writeReply);
324324
} else {
325325
writeReply();
326326
}
@@ -331,7 +331,9 @@ function dialog(query) {
331331
});
332332

333333
log('writing payload');
334-
socket.write(JSON.stringify(payload) + '\u0000', 'utf8');
334+
await new Promise(r => {
335+
socket.write(JSON.stringify(payload) + '\u0000', 'utf8', r);
336+
});
335337
log('payload written');
336338
});
337339
socket.setEncoding('utf8');
@@ -426,17 +428,17 @@ log(`socket path = ${sockPath}`);
426428
log(`action = ${action}`);
427429

428430
switch (action) {
429-
case 'get':
430-
get();
431-
break;
432-
case 'store':
433-
store();
434-
break;
435-
case 'erase':
436-
erase();
437-
break;
438-
default:
439-
log(`Unrecognized command: ${action}`);
440-
process.exit(0);
441-
break;
431+
case 'get':
432+
get();
433+
break;
434+
case 'store':
435+
store();
436+
break;
437+
case 'erase':
438+
erase();
439+
break;
440+
default:
441+
log(`Unrecognized command: ${action}`);
442+
process.exit(0);
443+
break;
442444
}

lib/atom/uri-pattern.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ export default class URIPattern {
5858
}
5959

6060
matches(string) {
61+
if (string === undefined || string === null) {
62+
return nonURIMatch;
63+
}
64+
6165
const other = url.parse(string, true);
6266
const params = {};
6367

lib/controllers/root-controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ export default class RootController extends React.Component {
648648
detailedMessage: `for the following files:\n${conflictedFiles}\n` +
649649
'Would you like to apply the changes with merge conflict markers, ' +
650650
'or open the text with merge conflict markers in a new file?',
651-
buttons: ['Merge with conflict markers', 'Open in new file', 'Cancel undo'],
651+
buttons: ['Merge with conflict markers', 'Open in new file', 'Cancel'],
652652
});
653653
if (choice === 0) {
654654
await this.proceedWithLastDiscardUndo(results, partialDiscardFilePath);

lib/get-repo-pipeline-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function({confirm, notificationManager, workspace}) {
1919
const choice = confirm({
2020
message: 'Are you sure you want to force push?',
2121
detailedMessage: 'This operation could result in losing data on the remote.',
22-
buttons: ['Force Push', 'Cancel Push'],
22+
buttons: ['Force Push', 'Cancel'],
2323
});
2424
if (choice !== 0) { /* do nothing */ } else { await next(); }
2525
} else {

lib/git-shell-out-strategy.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,18 @@ export default class GitShellOutStrategy {
217217
// process does not terminate when the git process is killed.
218218
// Kill the handler process *after* the git process has been killed to ensure that git doesn't have a
219219
// chance to fall back to GIT_ASKPASS from the credential handler.
220-
require('tree-kill')(handlerPid);
220+
await new Promise((resolveKill, rejectKill) => {
221+
require('tree-kill')(handlerPid, 'SIGTERM', err => {
222+
if (err) { rejectKill(err); } else { resolveKill(); }
223+
});
224+
});
221225
}));
222226
}
223227

224-
const {stdout, stderr, exitCode, timing} = await promise.catch(err => {
228+
const {stdout, stderr, exitCode, signal, timing} = await promise.catch(err => {
229+
if (err.signal) {
230+
return {signal: err.signal};
231+
}
225232
reject(err);
226233
return {};
227234
});
@@ -244,14 +251,20 @@ export default class GitShellOutStrategy {
244251

245252
if (diagnosticsEnabled) {
246253
const exposeControlCharacters = raw => {
254+
if (!raw) { return ''; }
255+
247256
return raw
248257
.replace(/\u0000/ug, '<NUL>\n')
249258
.replace(/\u001F/ug, '<SEP>');
250259
};
251260

252261
if (headless) {
253262
let summary = `git:${formattedArgs}\n`;
254-
summary += `exit status: ${exitCode}\n`;
263+
if (exitCode !== undefined) {
264+
summary += `exit status: ${exitCode}\n`;
265+
} else if (signal) {
266+
summary += `exit signal: ${signal}\n`;
267+
}
255268
summary += 'stdout:';
256269
if (stdout.length === 0) {
257270
summary += ' <empty>\n';
@@ -270,7 +283,11 @@ export default class GitShellOutStrategy {
270283
const headerStyle = 'font-weight: bold; color: blue;';
271284

272285
console.groupCollapsed(`git:${formattedArgs}`);
273-
console.log('%cexit status%c %d', headerStyle, 'font-weight: normal; color: black;', exitCode);
286+
if (exitCode !== undefined) {
287+
console.log('%cexit status%c %d', headerStyle, 'font-weight: normal; color: black;', exitCode);
288+
} else if (signal) {
289+
console.log('%cexit signal%c %s', headerStyle, 'font-weight: normal; color: black;', signal);
290+
}
274291
console.log(
275292
'%cfull arguments%c %s',
276293
headerStyle, 'font-weight: normal; color: black;',
@@ -339,7 +356,17 @@ export default class GitShellOutStrategy {
339356
marker && marker.mark('execute');
340357
return {
341358
promise,
342-
cancel: () => childPid && require('tree-kill')(childPid),
359+
cancel: () => {
360+
if (!childPid) {
361+
return Promise.resolve();
362+
}
363+
364+
return new Promise((resolve, reject) => {
365+
require('tree-kill')(childPid, 'SIGTERM', err => {
366+
if (err) { reject(err); } else { resolve(); }
367+
});
368+
});
369+
},
343370
};
344371
} else {
345372
const workerManager = this.workerManager || WorkerManager.getInstance();

lib/worker.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,27 @@ ipc.on(channelName, (event, {type, data}) => {
110110
results: {stdout, stderr, exitCode, timing},
111111
},
112112
});
113+
}, err => {
114+
const timing = {
115+
spawnTime: spawnEnd - spawnStart,
116+
execTime: performance.now() - spawnEnd,
117+
};
118+
childPidsById.delete(id);
119+
event.sender.sendTo(managerWebContentsId, channelName, {
120+
sourceWebContentsId,
121+
type: 'git-data',
122+
data: {
123+
id,
124+
average: averageTracker.getAverage(),
125+
results: {
126+
stdout: err.stdout,
127+
stderr: err.stderr,
128+
exitCode: err.code,
129+
signal: err.signal,
130+
timing,
131+
},
132+
},
133+
});
113134
});
114135
const spawnEnd = performance.now();
115136
averageTracker.addValue(spawnEnd - spawnStart);

0 commit comments

Comments
 (0)