Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@changesets/get-github-info

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@changesets/get-github-info - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

src/index.test.ts

10

CHANGELOG.md
# @changesets/get-github-info
## 0.4.0
### Minor Changes
- [`938823f`](https://github.com/atlassian/changesets/commit/938823f6fa0277869f0aecc3345c3812d1e44bba) [#224](https://github.com/atlassian/changesets/pull/224) - Show the PR author of a change rather than the author of the commit that added a changeset to account for cases when maintainers add a changeset to a PR and merge the PR with a merge commit
### Patch Changes
- [`938823f`](https://github.com/atlassian/changesets/commit/938823f6fa0277869f0aecc3345c3812d1e44bba) [#224](https://github.com/atlassian/changesets/pull/224) - Fix cases where the wrong PR is returned when a commit is associated with multiple PRs
## 0.3.0

@@ -4,0 +14,0 @@

39

dist/get-github-info.cjs.dev.js

@@ -22,6 +22,7 @@ 'use strict';

commitUrl
associatedPullRequests(first: 1) {
associatedPullRequests(first: 50) {
nodes {
number
url
mergedAt
}

@@ -101,9 +102,37 @@ }

const data = await GHDataLoader.load(request);
let user = null;
if (data.author && data.author.user) {
user = data.author.user;
}
let associatedPullRequest = data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes.length ? data.associatedPullRequests.nodes.sort((a, b) => {
if (a.mergedAt === null && b.mergedAt === null) {
return 0;
}
if (a.mergedAt === null) {
return 1;
}
if (b.mergedAt === null) {
return -1;
}
a = new Date(a.mergedAt);
b = new Date(b.mergedAt);
return a > b ? 1 : a < b ? -1 : 0;
})[0] : null;
if (associatedPullRequest) {
user = associatedPullRequest.author;
}
return {
user: data.author && data.author.user ? data.author.user.login : null,
pull: data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes[0] ? data.associatedPullRequests.nodes[0].number : null,
user: user ? user.login : null,
pull: associatedPullRequest ? associatedPullRequest.number : null,
links: {
commit: `[\`${request.commit}\`](${data.commitUrl})`,
pull: data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes[0] ? `[#${data.associatedPullRequests.nodes[0].number}](${data.associatedPullRequests.nodes[0].url})` : null,
user: data.author && data.author.user ? `[@${data.author.user.login}](${data.author.user.url})` : null
pull: associatedPullRequest ? `[#${associatedPullRequest.number}](${associatedPullRequest.url})` : null,
user: user ? `[@${user.login}](${user.url})` : null
}

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

15

dist/get-github-info.cjs.prod.js

@@ -14,3 +14,3 @@ "use strict";

function makeQuery(repos) {
return `\n query {\n ${Object.keys(repos).map((repo, i) => `a${i}: repository(\n owner: ${JSON.stringify(repo.split("/")[0])}\n name: ${JSON.stringify(repo.split("/")[1])}\n ) {\n ${repos[repo].map(commit => `a${commit}: object(expression: ${JSON.stringify(commit)}) {\n ... on Commit {\n commitUrl\n associatedPullRequests(first: 1) {\n nodes {\n number\n url\n }\n }\n author {\n user {\n login\n url\n }\n }\n }}`).join("\n")}\n }`).join("\n")}\n }\n `;
return `\n query {\n ${Object.keys(repos).map((repo, i) => `a${i}: repository(\n owner: ${JSON.stringify(repo.split("/")[0])}\n name: ${JSON.stringify(repo.split("/")[1])}\n ) {\n ${repos[repo].map(commit => `a${commit}: object(expression: ${JSON.stringify(commit)}) {\n ... on Commit {\n commitUrl\n associatedPullRequests(first: 50) {\n nodes {\n number\n url\n mergedAt\n }\n }\n author {\n user {\n login\n url\n }\n }\n }}`).join("\n")}\n }`).join("\n")}\n }\n `;
}

@@ -42,9 +42,12 @@

const data = await GHDataLoader.load(request);
return {
user: data.author && data.author.user ? data.author.user.login : null,
pull: data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes[0] ? data.associatedPullRequests.nodes[0].number : null,
let user = null;
data.author && data.author.user && (user = data.author.user);
let associatedPullRequest = data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes.length ? data.associatedPullRequests.nodes.sort((a, b) => null === a.mergedAt && null === b.mergedAt ? 0 : null === a.mergedAt ? 1 : null === b.mergedAt ? -1 : (a = new Date(a.mergedAt)) > (b = new Date(b.mergedAt)) ? 1 : a < b ? -1 : 0)[0] : null;
return associatedPullRequest && (user = associatedPullRequest.author), {
user: user ? user.login : null,
pull: associatedPullRequest ? associatedPullRequest.number : null,
links: {
commit: `[\`${request.commit}\`](${data.commitUrl})`,
pull: data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes[0] ? `[#${data.associatedPullRequests.nodes[0].number}](${data.associatedPullRequests.nodes[0].url})` : null,
user: data.author && data.author.user ? `[@${data.author.user.login}](${data.author.user.url})` : null
pull: associatedPullRequest ? `[#${associatedPullRequest.number}](${associatedPullRequest.url})` : null,
user: user ? `[@${user.login}](${user.url})` : null
}

@@ -51,0 +54,0 @@ };

@@ -16,6 +16,7 @@ import fetch from 'node-fetch';

commitUrl
associatedPullRequests(first: 1) {
associatedPullRequests(first: 50) {
nodes {
number
url
mergedAt
}

@@ -95,9 +96,37 @@ }

const data = await GHDataLoader.load(request);
let user = null;
if (data.author && data.author.user) {
user = data.author.user;
}
let associatedPullRequest = data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes.length ? data.associatedPullRequests.nodes.sort((a, b) => {
if (a.mergedAt === null && b.mergedAt === null) {
return 0;
}
if (a.mergedAt === null) {
return 1;
}
if (b.mergedAt === null) {
return -1;
}
a = new Date(a.mergedAt);
b = new Date(b.mergedAt);
return a > b ? 1 : a < b ? -1 : 0;
})[0] : null;
if (associatedPullRequest) {
user = associatedPullRequest.author;
}
return {
user: data.author && data.author.user ? data.author.user.login : null,
pull: data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes[0] ? data.associatedPullRequests.nodes[0].number : null,
user: user ? user.login : null,
pull: associatedPullRequest ? associatedPullRequest.number : null,
links: {
commit: `[\`${request.commit}\`](${data.commitUrl})`,
pull: data.associatedPullRequests && data.associatedPullRequests.nodes && data.associatedPullRequests.nodes[0] ? `[#${data.associatedPullRequests.nodes[0].number}](${data.associatedPullRequests.nodes[0].url})` : null,
user: data.author && data.author.user ? `[@${data.author.user.login}](${data.author.user.url})` : null
pull: associatedPullRequest ? `[#${associatedPullRequest.number}](${associatedPullRequest.url})` : null,
user: user ? `[@${user.login}](${user.url})` : null
}

@@ -104,0 +133,0 @@ };

{
"name": "@changesets/get-github-info",
"version": "0.3.0",
"version": "0.4.0",
"description": "Get the GitHub username and PR number from a commit. Intended for use with changesets.",

@@ -12,3 +12,7 @@ "main": "dist/get-github-info.cjs.js",

"node-fetch": "^2.5.0"
},
"devDependencies": {
"nock": "^11.7.0",
"prettier": "^1.18.2"
}
}

@@ -24,6 +24,7 @@ // @ts-ignore

commitUrl
associatedPullRequests(first: 1) {
associatedPullRequests(first: 50) {
nodes {
number
url
mergedAt
}

@@ -123,26 +124,40 @@ }

const data = await GHDataLoader.load(request);
let user = null;
if (data.author && data.author.user) {
user = data.author.user;
}
let associatedPullRequest =
data.associatedPullRequests &&
data.associatedPullRequests.nodes &&
data.associatedPullRequests.nodes.length
? (data.associatedPullRequests.nodes as any[]).sort((a, b) => {
if (a.mergedAt === null && b.mergedAt === null) {
return 0;
}
if (a.mergedAt === null) {
return 1;
}
if (b.mergedAt === null) {
return -1;
}
a = new Date(a.mergedAt);
b = new Date(b.mergedAt);
return a > b ? 1 : a < b ? -1 : 0;
})[0]
: null;
if (associatedPullRequest) {
user = associatedPullRequest.author;
}
return {
user: data.author && data.author.user ? data.author.user.login : null,
pull:
data.associatedPullRequests &&
data.associatedPullRequests.nodes &&
data.associatedPullRequests.nodes[0]
? data.associatedPullRequests.nodes[0].number
: null,
user: user ? user.login : null,
pull: associatedPullRequest ? associatedPullRequest.number : null,
links: {
commit: `[\`${request.commit}\`](${data.commitUrl})`,
pull:
data.associatedPullRequests &&
data.associatedPullRequests.nodes &&
data.associatedPullRequests.nodes[0]
? `[#${data.associatedPullRequests.nodes[0].number}](${
data.associatedPullRequests.nodes[0].url
})`
: null,
user:
data.author && data.author.user
? `[@${data.author.user.login}](${data.author.user.url})`
: null
pull: associatedPullRequest
? `[#${associatedPullRequest.number}](${associatedPullRequest.url})`
: null,
user: user ? `[@${user.login}](${user.url})` : null
}
};
}
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