Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/git-shell-out-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ export default class GitShellOutStrategy {

constructor(workingDir, options = {}) {
this.workingDir = workingDir;
const parallelism = options.parallelism || Math.max(3, os.cpus().length);
this.commandQueue = new AsyncQueue({parallelism});
if (options.queue) {
this.commandQueue = options.queue;
} else {
const parallelism = options.parallelism || Math.max(3, os.cpus().length);
this.commandQueue = new AsyncQueue({parallelism});
}

}

// Execute a command and read the output using the embedded Git environment
Expand Down
17 changes: 17 additions & 0 deletions lib/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import fs from 'fs-extra';
import {ncp} from 'ncp';

/**
* Takes an array of targets and returns a proxy. The proxy intercepts property accessor calls and
* returns the value of that property on the first object in `targets` where the target implements that property.
*/
export function firstImplementer(...targets) {
return new Proxy(targets, {
get(target, name) {
const firstValidTarget = target.find(t => Reflect.has(t, name));
if (firstValidTarget) {
return firstValidTarget[name];
} else {
return undefined;
}
},
});
}

export function readFile(absoluteFilePath, encoding = 'utf8') {
return new Promise((resolve, reject) => {
fs.readFile(absoluteFilePath, encoding, (err, contents) => {
Expand Down
12 changes: 10 additions & 2 deletions lib/views/git-timings-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,19 @@ class MarkerSpan extends React.Component {
});
}

@autobind
handleMouseOut(e) {
closeTooltip() {
this.tooltipDisposable && this.tooltipDisposable.dispose();
this.tooltipDisposable = null;
}

@autobind
handleMouseOut(e) {
this.closeTooltip();
}

componentWillUnmount() {
this.closeTooltip();
}
}


Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"multi-list-selection": "^0.1.1",
"ncp": "^2.0.0",
"node-fetch": "^1.6.3",
"nodegit": "^0.17.0",
"nsfw": "1.0.15",
"react": "^15.4.1",
"react-dom": "^15.4.1",
Expand Down
3 changes: 2 additions & 1 deletion test/git-shell-out-strategy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,11 @@ describe('Git commands', function() {
await git.exec(['remote', 'add', 'upstream', 'git@github.com:my/upstream.git']);
await git.exec(['remote', 'add', 'another.remote', 'git@github.com:another/upstream.git']);
const remotes = await git.getRemotes();
// Note: nodegit returns remote names in alphabetical order
assert.deepEqual(remotes, [
{name: 'another.remote', url: 'git@github.com:another/upstream.git'},
{name: 'origin', url: 'git@github.com:other/origin.git'},
{name: 'upstream', url: 'git@github.com:my/upstream.git'},
{name: 'another.remote', url: 'git@github.com:another/upstream.git'},
]);
});

Expand Down
20 changes: 20 additions & 0 deletions test/helpers.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {firstImplementer} from '../lib/helpers';

class A {
one() { return 'a-one'; }
two() { return 'a-two'; }
}

class B {
two() { return 'b-two'; }
three() { return 'b-three'; }
}

describe('firstImplementer', function() {
it('calls methods from the first target that has the method', function() {
const target = firstImplementer(new A(), new B());
assert.equal(target.one(), 'a-one');
assert.equal(target.two(), 'a-two');
assert.equal(target.three(), 'b-three');
});
});