Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
@changesets/get-github-info
Advanced tools
Get the GitHub username and PR number from a commit. Intended for use with changesets.
@changesets/get-github-info is an npm package that provides utilities for fetching information from GitHub, such as commit details, pull request information, and user data. It is particularly useful for projects that need to integrate GitHub data into their workflows, such as generating changelogs or automating release notes.
Get Commit Info
This feature allows you to fetch detailed information about a specific commit in a GitHub repository. The `getInfo` function takes an object with the repository name and commit SHA, and returns information such as the commit message, author, and associated pull requests.
const { getInfo } = require('@changesets/get-github-info');
async function getCommitInfo(commitSha) {
const info = await getInfo({ repo: 'owner/repo', commit: commitSha });
console.log(info);
}
getCommitInfo('commitSha');
Get Pull Request Info
This feature allows you to fetch detailed information about a specific pull request in a GitHub repository. The `getInfo` function takes an object with the repository name and pull request number, and returns information such as the title, author, and associated commits.
const { getInfo } = require('@changesets/get-github-info');
async function getPullRequestInfo(prNumber) {
const info = await getInfo({ repo: 'owner/repo', pull: prNumber });
console.log(info);
}
getPullRequestInfo(123);
Get User Info
This feature allows you to fetch detailed information about a specific GitHub user. The `getUserInfo` function takes a username and returns information such as the user's name, bio, and public repositories.
const { getUserInfo } = require('@changesets/get-github-info');
async function getUserInfo(username) {
const info = await getUserInfo(username);
console.log(info);
}
getUserInfo('username');
The `node-fetch` package is a lightweight module that brings `window.fetch` to Node.js. While it is not specifically designed for GitHub, it can be used to make HTTP requests to the GitHub API. Compared to @changesets/get-github-info, `node-fetch` requires more manual setup and handling of API endpoints and responses.
`gh-got` is a convenience wrapper around the `got` HTTP request library, specifically tailored for GitHub API requests. It simplifies authentication and request handling for GitHub. Compared to @changesets/get-github-info, `gh-got` provides more flexibility in making custom API requests but requires more manual configuration for specific use cases.
Get the GitHub username and PR number from a commit. Intended for use with changesets.
Note: This assumes you already have changesets setup.
To use @changesets/get-github-info
, you'll need to install it and you'll probably also want dotenv
to provide a GitHub personal access token via a .env
file.
yarn add --dev @changesets/get-github-info dotenv
or
npm install --save-dev @changesets/get-github-info dotenv
Then you can use it in your .changeset/config.js
like this.
require("dotenv").config();
const { getInfo } = require("@changesets/get-github-info");
// ...
const getReleaseLine = async (changeset, type) => {
const [firstLine, ...futureLines] = changeset.summary
.split("\n")
.map(l => l.trimRight());
// getInfo exposes the GH username and PR number if you want them directly
// but it also exposes a set of links for the commit, PR and GH username
let { user, pull, links } = await getInfo({
// replace this will your own repo
repo: "Noviny/changesets",
commit: changeset.commit
});
let returnVal = `- ${links.commit}${
links.pull === null ? "" : ` ${links.pull}`
}${links.user === null ? "" : ` Thanks ${links.user}!`}: ${firstLine}`;
if (futureLines.length > 0) {
returnVal += `\n${futureLines.map(l => ` ${l}`).join("\n")}`;
}
return returnVal;
};
// ...
You'll need to get a GitHub personal access token with read:user
and repo:status
permissions, and add it to a .env
file.
GITHUB_TOKEN=token_here
You can now bump your packages and changelogs with changeset bump
and it'll have the GitHub info. 🎉
type Info = {
user: string | null;
pull: number | null;
links: {
commit: string;
pull: string | null;
user: string | null;
};
};
type Options = {
commit: string;
repo: string;
};
export function getInfo(options: Options): Info {
// magic...
}
FAQs
Get the GitHub username and PR number from a commit. Intended for use with changesets.
The npm package @changesets/get-github-info receives a total of 270,538 weekly downloads. As such, @changesets/get-github-info popularity was classified as popular.
We found that @changesets/get-github-info demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.