New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@backstroke/worker

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backstroke/worker - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

2

package.json
{
"name": "@backstroke/worker",
"version": "2.0.0",
"version": "2.1.0",
"dependencies": {

@@ -5,0 +5,0 @@ "bluebird": "^3.5.0",

@@ -126,9 +126,9 @@ const GitHubApi = require('github');

// The pull request already existed
debug(`Already a pull request on ${link.forkOwner}/${link.forkRepo} from ${link.upstreamOwner}/${link.upstreamRepo}`);
debug(`Already a pull request on ${fork.owner}/${fork.repo} from ${link.upstreamOwner}/${link.upstreamRepo}`);
resolve(`There's already a pull request on ${link.forkOwner}/${link.forkRepo}`);
} else if (err) {
// Still reject anything else
reject(new Error(`Couldn't create pull request on repository ${link.forkOwner}/${link.forkRepo}: ${err.message ? err.message : err}`));
reject(new Error(`Couldn't create pull request on repository ${fork.owner}/${fork.repo}: ${err.message ? err.message : err}`));
} else {
resolve(`Successfully created pull request on ${link.forkOwner}/${link.forkRepo}`);
resolve(`Successfully created pull request on ${fork.owner}/${fork.repo}`);
}

@@ -135,0 +135,0 @@ });

@@ -89,14 +89,19 @@ const paginateRequest = require('./helpers').paginateRequest;

return createPullRequest(
user,
link,
{
owner: fork.owner.login,
repo: fork.name,
branch: link.forkBranch,
},
debug,
didRepoOptOut,
githubPullRequestsCreate
);
try {
const data = await createPullRequest(
user,
link,
{
owner: fork.owner.login,
repo: fork.name,
branch: link.forkBranch,
},
debug,
didRepoOptOut,
githubPullRequestsCreate
);
return {status: 'OK', data};
} catch (error) {
return {status: 'ERROR', error: error.message};
}
});

@@ -107,3 +112,7 @@

many: true,
forkCount: data.length, // total amount of forks handled
metrics: {
total: data.length,
successes: data.filter(i => i.status === 'OK').length,
},
errors: data.filter(i => i.status === 'ERROR'),
isEnabled: true,

@@ -110,0 +119,0 @@ };

@@ -185,4 +185,5 @@ const sinon = require('sinon');

assert.deepEqual(response.output, {
forkCount: 2,
many: true,
metrics: {total: 2, successes: 2},
errors: [],
isEnabled: true,

@@ -194,2 +195,3 @@ });

});
it('should try to make a PR to a single fork of an upstream, but the repo opted out', async () => {

@@ -631,2 +633,92 @@ const createPullRequest = require('./helpers').createPullRequest;

});
it('should create a pull request on each fork when given a bunch of forks, but one fails', async () => {
const createPullRequest = require('./helpers').createPullRequest;
const getForksForRepo = sinon.stub().resolves([
{owner: {login: 'hello'}, name: 'world'},
{owner: {login: 'another'}, name: 'repo'},
]);
const didRepoOptOut = sinon.stub().resolves(false);
const pullRequestMock = sinon.stub();
pullRequestMock.onCall(0).yields(null);
pullRequestMock.onCall(1).yields(new Error('Something bad happened.'));
const githubPullRequestsCreate = () => pullRequestMock;
const enqueuedAs = await MockWebhookQueue.push({
type: 'MANUAL',
user: {
id: 1,
username: '1egoman',
email: null,
githubId: '1704236',
accessToken: 'ACCESS TOKEN',
publicScope: false,
createdAt: '2017-08-09T12:00:36.000Z',
lastLoggedInAt: '2017-08-16T12:50:40.203Z',
updatedAt: '2017-08-16T12:50:40.204Z',
},
link: {
id: 8,
name: 'foo',
enabled: true,
webhookId: '37948270678a440a97db01ebe71ddda2',
lastSyncedAt: '2017-08-17T11:37:22.999Z',
upstreamType: 'repo',
upstreamOwner: '1egoman',
upstreamRepo: 'biome',
upstreamIsFork: null,
upstreamBranches: '["inject","master"]',
upstreamBranch: 'master',
forkType: 'fork-all',
forkOwner: undefined,
forkRepo: undefined,
forkBranches: undefined,
forkBranch: undefined,
createdAt: '2017-08-11T10:17:09.614Z',
updatedAt: '2017-08-17T11:37:23.001Z',
ownerId: 1,
owner: {
id: 1,
username: '1egoman',
email: null,
githubId: '1704236',
accessToken: 'ACCESS TOKEN',
publicScope: false,
createdAt: '2017-08-09T12:00:36.000Z',
lastLoggedInAt: '2017-08-16T12:50:40.203Z',
updatedAt: '2017-08-16T12:50:40.204Z',
},
},
});
// Run the worker that eats off the queue.
await processBatch(
MockWebhookQueue,
MockWebhookStatusStore,
() => null, //console.log.bind(console, '* '),
getForksForRepo,
createPullRequest,
didRepoOptOut,
githubPullRequestsCreate
);
// Make sure that it worked
const response = MockWebhookStatusStore.keys[enqueuedAs].status;
assert.equal(response.status, 'OK');
assert.deepEqual(response.output, {
many: true,
metrics: {total: 2, successes: 1},
errors: [
{
status: 'ERROR',
error: `Couldn't create pull request on repository another/repo: Something bad happened.`,
},
],
isEnabled: true,
});
// Should have created two pull requests.
assert.equal(pullRequestMock.callCount, 2);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc