Skip to content

Commit

Permalink
Filter by commitish regardless of the refs/heads prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Bulash committed Feb 28, 2022
1 parent d8ca1fa commit a276477
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 44 deletions.
92 changes: 49 additions & 43 deletions dist/index.js
Expand Up @@ -77278,7 +77278,7 @@ module.exports = VerifyStream;
const path = __nccwpck_require__(71017);
const fs = __nccwpck_require__(77758);
const stripBom = __nccwpck_require__(88551);
const parseJson = __nccwpck_require__(81680);
const parseJson = __nccwpck_require__(86615);
const pify = __nccwpck_require__(64810);

const parse = (data, filePath, options = {}) => {
Expand All @@ -77299,47 +77299,6 @@ module.exports["default"] = loadJsonFile;
module.exports.sync = (filePath, options) => parse(fs.readFileSync(filePath, 'utf8'), filePath, options);


/***/ }),

/***/ 81680:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

"use strict";

const errorEx = __nccwpck_require__(23505);
const fallback = __nccwpck_require__(55586);

const JSONError = errorEx('JSONError', {
fileName: errorEx.append('in %s')
});

module.exports = (input, reviver, filename) => {
if (typeof reviver === 'string') {
filename = reviver;
reviver = null;
}

try {
try {
return JSON.parse(input, reviver);
} catch (err) {
fallback(input, reviver);

throw err;
}
} catch (err) {
err.message = err.message.replace(/\n/g, '');

const jsonErr = new JSONError(err);
if (filename) {
jsonErr.fileName = filename;
}

throw jsonErr;
}
};


/***/ }),

/***/ 11289:
Expand Down Expand Up @@ -104625,6 +104584,47 @@ module.exports = pTry;
module.exports["default"] = pTry;


/***/ }),

/***/ 86615:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

"use strict";

const errorEx = __nccwpck_require__(23505);
const fallback = __nccwpck_require__(55586);

const JSONError = errorEx('JSONError', {
fileName: errorEx.append('in %s')
});

module.exports = (input, reviver, filename) => {
if (typeof reviver === 'string') {
filename = reviver;
reviver = null;
}

try {
try {
return JSON.parse(input, reviver);
} catch (err) {
fallback(input, reviver);

throw err;
}
} catch (err) {
err.message = err.message.replace(/\n/g, '');

const jsonErr = new JSONError(err);
if (filename) {
jsonErr.fileName = filename;
}

throw jsonErr;
}
};


/***/ }),

/***/ 89808:
Expand Down Expand Up @@ -129086,8 +129086,14 @@ const findReleases = async ({

log({ context, message: `Found ${releases.length} releases` })

const headRefRegex = /^refs\/heads\//
const filteredReleases = filterByCommitish
? releases.filter((r) => targetCommitish.match(`/${r.target_commitish}$`))
? releases.filter(
(r) =>
// `refs/heads/branch` and `branch` are the same thing in this context
targetCommitish.replace(headRefRegex, '') ===
r.target_commitish.replace(headRefRegex, '')
)
: releases
const sortedPublishedReleases = sortReleases(
filteredReleases.filter((r) => !r.draft)
Expand Down
8 changes: 7 additions & 1 deletion lib/releases.js
Expand Up @@ -43,8 +43,14 @@ const findReleases = async ({

log({ context, message: `Found ${releases.length} releases` })

const headRefRegex = /^refs\/heads\//
const filteredReleases = filterByCommitish
? releases.filter((r) => targetCommitish.match(`/${r.target_commitish}$`))
? releases.filter(
(r) =>
// `refs/heads/branch` and `branch` are the same thing in this context
targetCommitish.replace(headRefRegex, '') ===
r.target_commitish.replace(headRefRegex, '')
)
: releases
const sortedPublishedReleases = sortReleases(
filteredReleases.filter((r) => !r.draft)
Expand Down

0 comments on commit a276477

Please sign in to comment.