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

release-please

Package Overview
Dependencies
Maintainers
2
Versions
383
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

release-please - npm Package Compare versions

Comparing version 6.4.2-candidate-2 to 6.4.2

8

build/src/github.d.ts

@@ -72,9 +72,3 @@ import { Octokit } from '@octokit/rest';

latestTag(prefix?: string, preRelease?: boolean): Promise<GitHubTag | undefined>;
latestTagFallback(prefix?: string, preRelease?: boolean): Promise<{
name: string;
sha: string;
version: string;
} | undefined>;
private allTags;
findMergedReleasePR(labels: string[], maxPRsChecked?: number, matcher?: RegExp | null): Promise<GitHubReleasePR | undefined>;
findMergedReleasePR(labels: string[], perPage?: number, matcher?: RegExp | null): Promise<GitHubReleasePR | undefined>;
private hasAllLabels;

@@ -81,0 +75,0 @@ findOpenReleasePRs(labels: string[], perPage?: number): Promise<PullsListResponseItems>;

203

build/src/github.js

@@ -25,8 +25,3 @@ "use strict";

const graphql_to_commits_1 = require("./graphql-to-commits");
// Short explanation of this regex:
// - skip the owner tag (e.g. googleapis)
// - make sure the branch name starts with "release"
// - skip everything up to the last "-v"
// - take everything after the v as a match group
const VERSION_FROM_BRANCH_RE = /^.*:release.*-v(?=[^v]+$)(.+)$/;
const VERSION_FROM_BRANCH_RE = /^.*:release-(.*)$/;
let probotMode = false;

@@ -122,31 +117,36 @@ class GitHub {

const response = await this.graphqlRequest({
query: `query commitsWithFiles($cursor: String, $owner: String!, $repo: String!, $baseRef: String!, $perPage: Int, $maxFilesChanged: Int, $path: String) {
query: `query commitsWithFiles($cursor: String, $owner: String!, $repo: String!, $baseBranch: String!, $perPage: Int, $maxFilesChanged: Int, $path: String) {
repository(owner: $owner, name: $repo) {
ref(qualifiedName: $baseRef) {
target {
... on Commit {
history(first: $perPage, after: $cursor, path: $path) {
edges {
node {
... on Commit {
message
oid
associatedPullRequests(first: 1) {
edges {
node {
... on PullRequest {
number
mergeCommit {
oid
}
files(first: $maxFilesChanged) {
edges {
node {
path
refs(first: 1, refPrefix: "refs/heads/", query: $baseBranch,
orderBy:{field:TAG_COMMIT_DATE, direction:DESC}) {
edges {
node {
target {
... on Commit {
history(first: $perPage, after: $cursor, path: $path) {
edges {
node {
... on Commit {
message
oid
associatedPullRequests(first: 1) {
edges {
node {
... on PullRequest {
number
mergeCommit {
oid
}
files(first: $maxFilesChanged) {
edges {
node {
path
}
}
pageInfo {
endCursor
hasNextPage
}
}
}
pageInfo {
endCursor
hasNextPage
}
}

@@ -158,8 +158,8 @@ }

}
pageInfo {
endCursor
hasNextPage
}
}
}
pageInfo {
endCursor
hasNextPage
}
}

@@ -177,3 +177,3 @@ }

repo: this.repo,
baseRef: `refs/heads/${baseBranch}`,
baseBranch,
});

@@ -313,5 +313,5 @@ return graphql_to_commits_1.graphqlToCommits(this, response);

const regexp = regexpString ? new RegExp(regexpString) : null;
const pull = await this.findMergedReleasePR([], 1024, regexp);
const pull = await this.findMergedReleasePR([], 100, regexp);
if (!pull)
return await this.latestTagFallback(prefix, preRelease);
return undefined;
const tag = {

@@ -324,98 +324,37 @@ name: `v${pull.version}`,

}
// If we can't find a release branch (a common cause of this, as an example
// is that we might be dealing with the first relese), use the last semver
// tag that's available on the repository:
// TODO: it would be good to not need to maintain this logic, and the
// logic that introspects version based on the prior release PR.
async latestTagFallback(prefix, preRelease = false) {
const tags = await this.allTags(prefix);
const versions = Object.keys(tags).filter(t => {
// remove any pre-releases from the list:
return preRelease || !t.includes('-');
});
// no tags have been created yet.
if (versions.length === 0)
return undefined;
// We use a slightly modified version of semver's sorting algorithm, which
// prefixes the numeric part of a pre-release with '0's, so that
// 010 is greater than > 002.
versions.sort((v1, v2) => {
if (v1.includes('-')) {
const [prefix, suffix] = v1.split('-');
v1 = prefix + '-' + suffix.replace(/[a-zA-Z.]/, '').padStart(6, '0');
}
if (v2.includes('-')) {
const [prefix, suffix] = v2.split('-');
v2 = prefix + '-' + suffix.replace(/[a-zA-Z.]/, '').padStart(6, '0');
}
return semver.rcompare(v1, v2);
});
return {
name: tags[versions[0]].name,
sha: tags[versions[0]].sha,
version: tags[versions[0]].version,
};
}
async allTags(prefix) {
const tags = {};
for await (const response of this.octokit.paginate.iterator(this.decoratePaginateOpts({
method: 'GET',
url: `/repos/${this.owner}/${this.repo}/tags?per_page=100${this.proxyKey ? `&key=${this.proxyKey}` : ''}`,
}))) {
response.data.forEach((data) => {
// For monorepos, a prefix can be provided, indicating that only tags
// matching the prefix should be returned:
if (prefix && !data.name.startsWith(prefix))
return;
let version = data.name.replace(prefix, '');
if ((version = semver.valid(version))) {
tags[version] = { sha: data.commit.sha, name: data.name, version };
}
});
}
return tags;
}
// The default matcher will rule out pre-releases.
async findMergedReleasePR(labels, maxPRsChecked = 100, matcher = /[^-]*/) {
async findMergedReleasePR(labels, perPage = 100, matcher = /[^-]*/) {
const baseLabel = await this.getBaseLabel();
let total = 0;
for await (const response of this.octokit.paginate.iterator(this.decoratePaginateOpts({
method: 'GET',
url: `/repos/${this.owner}/${this.repo}/pulls?per_page=25${this.proxyKey ? `&key=${this.proxyKey}` : ''}&state=closed&sort=updated&direction=desc`,
}))) {
const pullsResponse = response;
console.info(response);
for (let i = 0, pull; i < pullsResponse.data.length; i++) {
total++;
pull = pullsResponse.data[i];
if (labels.length === 0 ||
this.hasAllLabels(labels, pull.labels.map(l => l.name))) {
// it's expected that a release PR will have a
// HEAD matching the format repo:release-v1.0.0.
if (!pull.head)
continue;
// Verify that this PR was based against our base branch of interest.
if (!pull.base || pull.base.label !== baseLabel)
continue;
const match = pull.head.label.match(VERSION_FROM_BRANCH_RE);
if (!match || !pull.merged_at)
continue;
// Make sure we did get a valid semver.
const version = match[1];
const normalizedVersion = semver.valid(version);
if (!normalizedVersion)
continue;
// Does its name match any passed matcher?
if (matcher && !matcher.test(normalizedVersion))
continue;
return {
number: pull.number,
sha: pull.merge_commit_sha,
version: normalizedVersion,
};
}
const pullsResponse = (await this.request(`GET /repos/:owner/:repo/pulls?state=closed&per_page=${perPage}${this.proxyKey ? `&key=${this.proxyKey}` : ''}&sort=updated&direction=desc`, {
owner: this.owner,
repo: this.repo,
}));
for (let i = 0, pull; i < pullsResponse.data.length; i++) {
pull = pullsResponse.data[i];
if (labels.length === 0 ||
this.hasAllLabels(labels, pull.labels.map(l => l.name))) {
// it's expected that a release PR will have a
// HEAD matching the format repo:release-v1.0.0.
if (!pull.head)
continue;
// Verify that this PR was based against our base branch of interest.
if (!pull.base || pull.base.label !== baseLabel)
continue;
const match = pull.head.label.match(VERSION_FROM_BRANCH_RE);
if (!match || !pull.merged_at)
continue;
// Make sure we did get a valid semver.
const version = match[1];
const normalizedVersion = semver.valid(version);
if (!normalizedVersion)
continue;
// Does its name match any passed matcher?
if (matcher && !matcher.test(normalizedVersion))
continue;
return {
number: pull.number,
sha: pull.merge_commit_sha,
version: normalizedVersion,
};
}
console.info(total, maxPRsChecked);
if (total >= maxPRsChecked)
return undefined;
}

@@ -422,0 +361,0 @@ return undefined;

@@ -14,9 +14,15 @@ import { GitHub } from './github';

repository: {
ref: {
target: {
history: CommitHistory;
};
refs: {
edges: RefNode[];
};
};
}
interface RefNode {
node: RefTarget;
}
interface RefTarget {
target: {
history: CommitHistory;
};
}
interface CommitHistory {

@@ -23,0 +29,0 @@ edges: CommitEdge[];

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

async function graphqlToCommits(github, response) {
const commitHistory = response.repository.ref.target.history;
const commitHistory = response.repository.refs.edges[0].node.target.history;
const commits = {

@@ -22,0 +22,0 @@ endCursor: commitHistory.pageInfo.endCursor,

@@ -7,2 +7,9 @@ # Changelog

### [6.4.2](https://www.github.com/googleapis/release-please/compare/v6.4.1...v6.4.2) (2020-10-14)
### Bug Fixes
* **deps:** update dependency type-fest to ^0.18.0 ([#589](https://www.github.com/googleapis/release-please/issues/589)) ([66f44ef](https://www.github.com/googleapis/release-please/commit/66f44ef23dece7c366eb17db4bf09dcb43fcc41a))
### [6.4.1](https://www.github.com/googleapis/release-please/compare/v6.4.0...v6.4.1) (2020-10-08)

@@ -9,0 +16,0 @@

{
"name": "release-please",
"version": "6.4.2-candidate-2",
"version": "6.4.2",
"description": "generate release PRs based on the conventionalcommits.org spec",

@@ -74,3 +74,3 @@ "main": "./build/src/index.js",

"semver": "^7.0.0",
"type-fest": "^0.17.0",
"type-fest": "^0.18.0",
"yargs": "^16.0.0"

@@ -77,0 +77,0 @@ },

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