Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03334d095e | ||
|
|
8a0655f075 | ||
|
|
98e187efcd | ||
|
|
96f65726ea | ||
|
|
bf548e4af2 | ||
|
|
8b07fd3b11 | ||
|
|
d195e6e7c2 |
27
HISTORY.md
27
HISTORY.md
@@ -1,5 +1,32 @@
|
||||
# Changelog
|
||||
|
||||
# [44.5.0](https://github.com/tj-actions/changed-files/compare/v44.4.0...v44.5.0) - (2024-05-21)
|
||||
|
||||
## <!-- 0 -->🚀 Features
|
||||
|
||||
- Add support for providing patterns to match tags ([#2098](https://github.com/tj-actions/changed-files/issues/2098)) ([03c1842](https://github.com/tj-actions/changed-files/commit/03c184259aae3c160b1d7281389e51f97ea02e5e)) - (Tonye Jack)
|
||||
|
||||
## <!-- 26 -->🔄 Update
|
||||
|
||||
- Updated README.md ([#2099](https://github.com/tj-actions/changed-files/issues/2099))
|
||||
|
||||
Co-authored-by: jackton1 <17484350+jackton1@users.noreply.github.com> ([1754cd4](https://github.com/tj-actions/changed-files/commit/1754cd4b9e661d1f0eced3b33545a8d8b3bc46d8)) - (tj-actions[bot])
|
||||
|
||||
## <!-- 7 -->⚙️ Miscellaneous Tasks
|
||||
|
||||
- **deps:** Update typescript-eslint monorepo to v7.10.0 ([5f01393](https://github.com/tj-actions/changed-files/commit/5f0139347aeb65568e336f0250e84595c04c6c0a)) - (renovate[bot])
|
||||
- **deps:** Update dependency @types/lodash to v4.17.4 ([58a9886](https://github.com/tj-actions/changed-files/commit/58a98867a77169ecf0438862d98cc9eb4bfb3511)) - (renovate[bot])
|
||||
- **deps:** Update dependency @types/lodash to v4.17.3 ([9216b0c](https://github.com/tj-actions/changed-files/commit/9216b0cec231229441961c892fbdfcda247e6f59)) - (renovate[bot])
|
||||
- **deps:** Update dependency @types/node to v20.12.12 ([0e3a6c3](https://github.com/tj-actions/changed-files/commit/0e3a6c3e99b91fdd487b056c372f55c0c28e7eaf)) - (renovate[bot])
|
||||
- **deps:** Update typescript-eslint monorepo to v7.9.0 ([e86678f](https://github.com/tj-actions/changed-files/commit/e86678fe3aea7af0d378326a830158c186101136)) - (renovate[bot])
|
||||
- **deps:** Lock file maintenance ([35d5a4d](https://github.com/tj-actions/changed-files/commit/35d5a4d79f865a1a8db02b9f6fb4c5cd4b4809ef)) - (renovate[bot])
|
||||
|
||||
## <!-- 9 -->⬆️ Upgrades
|
||||
|
||||
- Upgraded to v44.4.0 ([#2086](https://github.com/tj-actions/changed-files/issues/2086))
|
||||
|
||||
Co-authored-by: jackton1 <17484350+jackton1@users.noreply.github.com> ([887f936](https://github.com/tj-actions/changed-files/commit/887f93673c5c7e05864f59ff35db2cc632163ce3)) - (tj-actions[bot])
|
||||
|
||||
# [44.4.0](https://github.com/tj-actions/changed-files/compare/v44.3.0...v44.4.0) - (2024-05-08)
|
||||
|
||||
## <!-- 0 -->🚀 Features
|
||||
|
||||
175
dist/index.js
generated
vendored
175
dist/index.js
generated
vendored
@@ -1058,7 +1058,8 @@ const getSHAForNonPullRequestEvent = (_j) => __awaiter(void 0, [_j], void 0, fun
|
||||
const { sha, tag } = yield (0, utils_1.getPreviousGitTag)({
|
||||
cwd: workingDirectory,
|
||||
tagsPattern: inputs.tagsPattern,
|
||||
tagsIgnorePattern: inputs.tagsIgnorePattern
|
||||
tagsIgnorePattern: inputs.tagsIgnorePattern,
|
||||
currentBranch
|
||||
});
|
||||
previousSha = sha;
|
||||
targetBranch = tag;
|
||||
@@ -2620,29 +2621,55 @@ const cleanShaInput = (_5) => __awaiter(void 0, [_5], void 0, function* ({ sha,
|
||||
return stdout.trim();
|
||||
});
|
||||
exports.cleanShaInput = cleanShaInput;
|
||||
const getPreviousGitTag = (_6) => __awaiter(void 0, [_6], void 0, function* ({ cwd, tagsPattern, tagsIgnorePattern }) {
|
||||
const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-creatordate'], {
|
||||
const getPreviousGitTag = (_6) => __awaiter(void 0, [_6], void 0, function* ({ cwd, tagsPattern, currentBranch, tagsIgnorePattern }) {
|
||||
const ignorePatterns = [];
|
||||
let currentShaDate = null;
|
||||
const { stdout } = yield exec.getExecOutput('git', [
|
||||
'tag',
|
||||
'--sort=-creatordate',
|
||||
'--format=%(refname:short)|%(objectname)|%(creatordate:iso)'
|
||||
], {
|
||||
cwd,
|
||||
silent: !core.isDebug()
|
||||
});
|
||||
let tags = stdout.trim().split('\n');
|
||||
if (tagsPattern) {
|
||||
tags = tags.filter(tag => micromatch_1.default.isMatch(tag, tagsPattern));
|
||||
}
|
||||
if (tagsIgnorePattern) {
|
||||
tags = tags.filter(tag => !micromatch_1.default.isMatch(tag, tagsIgnorePattern));
|
||||
ignorePatterns.push(tagsIgnorePattern);
|
||||
}
|
||||
if (tags.length < 2) {
|
||||
if (currentBranch) {
|
||||
ignorePatterns.push(currentBranch);
|
||||
try {
|
||||
const { stdout: currentShaDateOutput } = yield exec.getExecOutput('git', ['show', '-s', '--format=%ai', currentBranch], {
|
||||
cwd,
|
||||
silent: !core.isDebug()
|
||||
});
|
||||
currentShaDate = new Date(currentShaDateOutput.trim());
|
||||
}
|
||||
catch (error) {
|
||||
// Handle the case where the current branch doesn't exist
|
||||
// This might happen in detached head state
|
||||
core.warning(`Failed to get date for current branch ${currentBranch}`);
|
||||
}
|
||||
}
|
||||
const previousTag = { tag: '', sha: '' };
|
||||
const tags = stdout.trim().split('\n');
|
||||
for (const tagData of tags) {
|
||||
const [tag, sha, dateString] = tagData.split('|');
|
||||
if (!micromatch_1.default.isMatch(tag, tagsPattern) || micromatch_1.default.isMatch(tag, ignorePatterns)) {
|
||||
continue;
|
||||
}
|
||||
const date = new Date(dateString);
|
||||
if (currentShaDate && date >= currentShaDate) {
|
||||
continue;
|
||||
}
|
||||
// Found a suitable tag, no need to continue
|
||||
previousTag.tag = tag;
|
||||
previousTag.sha = sha;
|
||||
break;
|
||||
}
|
||||
if (!previousTag.tag) {
|
||||
core.warning('No previous tag found');
|
||||
return { tag: '', sha: '' };
|
||||
}
|
||||
const previousTag = tags[1];
|
||||
const { stdout: stdout2 } = yield exec.getExecOutput('git', ['rev-parse', previousTag], {
|
||||
cwd,
|
||||
silent: !core.isDebug()
|
||||
});
|
||||
const sha = stdout2.trim();
|
||||
return { tag: previousTag, sha };
|
||||
return previousTag;
|
||||
});
|
||||
exports.getPreviousGitTag = getPreviousGitTag;
|
||||
const canDiffCommits = (_7) => __awaiter(void 0, [_7], void 0, function* ({ cwd, sha1, sha2, diff }) {
|
||||
@@ -16136,8 +16163,8 @@ const braces = (input, options = {}) => {
|
||||
let output = [];
|
||||
|
||||
if (Array.isArray(input)) {
|
||||
for (let pattern of input) {
|
||||
let result = braces.create(pattern, options);
|
||||
for (const pattern of input) {
|
||||
const result = braces.create(pattern, options);
|
||||
if (Array.isArray(result)) {
|
||||
output.push(...result);
|
||||
} else {
|
||||
@@ -16271,7 +16298,7 @@ braces.create = (input, options = {}) => {
|
||||
return [input];
|
||||
}
|
||||
|
||||
return options.expand !== true
|
||||
return options.expand !== true
|
||||
? braces.compile(input, options)
|
||||
: braces.expand(input, options);
|
||||
};
|
||||
@@ -16295,30 +16322,32 @@ const fill = __nccwpck_require__(6330);
|
||||
const utils = __nccwpck_require__(5207);
|
||||
|
||||
const compile = (ast, options = {}) => {
|
||||
let walk = (node, parent = {}) => {
|
||||
let invalidBlock = utils.isInvalidBrace(parent);
|
||||
let invalidNode = node.invalid === true && options.escapeInvalid === true;
|
||||
let invalid = invalidBlock === true || invalidNode === true;
|
||||
let prefix = options.escapeInvalid === true ? '\\' : '';
|
||||
const walk = (node, parent = {}) => {
|
||||
const invalidBlock = utils.isInvalidBrace(parent);
|
||||
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
||||
const invalid = invalidBlock === true || invalidNode === true;
|
||||
const prefix = options.escapeInvalid === true ? '\\' : '';
|
||||
let output = '';
|
||||
|
||||
if (node.isOpen === true) {
|
||||
return prefix + node.value;
|
||||
}
|
||||
|
||||
if (node.isClose === true) {
|
||||
console.log('node.isClose', prefix, node.value);
|
||||
return prefix + node.value;
|
||||
}
|
||||
|
||||
if (node.type === 'open') {
|
||||
return invalid ? (prefix + node.value) : '(';
|
||||
return invalid ? prefix + node.value : '(';
|
||||
}
|
||||
|
||||
if (node.type === 'close') {
|
||||
return invalid ? (prefix + node.value) : ')';
|
||||
return invalid ? prefix + node.value : ')';
|
||||
}
|
||||
|
||||
if (node.type === 'comma') {
|
||||
return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
|
||||
return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
|
||||
}
|
||||
|
||||
if (node.value) {
|
||||
@@ -16326,8 +16355,8 @@ const compile = (ast, options = {}) => {
|
||||
}
|
||||
|
||||
if (node.nodes && node.ranges > 0) {
|
||||
let args = utils.reduce(node.nodes);
|
||||
let range = fill(...args, { ...options, wrap: false, toRegex: true });
|
||||
const args = utils.reduce(node.nodes);
|
||||
const range = fill(...args, { ...options, wrap: false, toRegex: true, strictZeros: true });
|
||||
|
||||
if (range.length !== 0) {
|
||||
return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
||||
@@ -16335,10 +16364,11 @@ const compile = (ast, options = {}) => {
|
||||
}
|
||||
|
||||
if (node.nodes) {
|
||||
for (let child of node.nodes) {
|
||||
for (const child of node.nodes) {
|
||||
output += walk(child, node);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
@@ -16357,7 +16387,7 @@ module.exports = compile;
|
||||
|
||||
|
||||
module.exports = {
|
||||
MAX_LENGTH: 1024 * 64,
|
||||
MAX_LENGTH: 10000,
|
||||
|
||||
// Digits
|
||||
CHAR_0: '0', /* 0 */
|
||||
@@ -16426,7 +16456,7 @@ const stringify = __nccwpck_require__(1514);
|
||||
const utils = __nccwpck_require__(5207);
|
||||
|
||||
const append = (queue = '', stash = '', enclose = false) => {
|
||||
let result = [];
|
||||
const result = [];
|
||||
|
||||
queue = [].concat(queue);
|
||||
stash = [].concat(stash);
|
||||
@@ -16436,15 +16466,15 @@ const append = (queue = '', stash = '', enclose = false) => {
|
||||
return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash;
|
||||
}
|
||||
|
||||
for (let item of queue) {
|
||||
for (const item of queue) {
|
||||
if (Array.isArray(item)) {
|
||||
for (let value of item) {
|
||||
for (const value of item) {
|
||||
result.push(append(value, stash, enclose));
|
||||
}
|
||||
} else {
|
||||
for (let ele of stash) {
|
||||
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
|
||||
result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
|
||||
result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16452,9 +16482,9 @@ const append = (queue = '', stash = '', enclose = false) => {
|
||||
};
|
||||
|
||||
const expand = (ast, options = {}) => {
|
||||
let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
|
||||
const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
|
||||
|
||||
let walk = (node, parent = {}) => {
|
||||
const walk = (node, parent = {}) => {
|
||||
node.queue = [];
|
||||
|
||||
let p = parent;
|
||||
@@ -16476,7 +16506,7 @@ const expand = (ast, options = {}) => {
|
||||
}
|
||||
|
||||
if (node.nodes && node.ranges > 0) {
|
||||
let args = utils.reduce(node.nodes);
|
||||
const args = utils.reduce(node.nodes);
|
||||
|
||||
if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
|
||||
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
||||
@@ -16492,7 +16522,7 @@ const expand = (ast, options = {}) => {
|
||||
return;
|
||||
}
|
||||
|
||||
let enclose = utils.encloseBrace(node);
|
||||
const enclose = utils.encloseBrace(node);
|
||||
let queue = node.queue;
|
||||
let block = node;
|
||||
|
||||
@@ -16502,7 +16532,7 @@ const expand = (ast, options = {}) => {
|
||||
}
|
||||
|
||||
for (let i = 0; i < node.nodes.length; i++) {
|
||||
let child = node.nodes[i];
|
||||
const child = node.nodes[i];
|
||||
|
||||
if (child.type === 'comma' && node.type === 'brace') {
|
||||
if (i === 1) queue.push('');
|
||||
@@ -16575,22 +16605,21 @@ const parse = (input, options = {}) => {
|
||||
throw new TypeError('Expected a string');
|
||||
}
|
||||
|
||||
let opts = options || {};
|
||||
let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
||||
const opts = options || {};
|
||||
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
||||
if (input.length > max) {
|
||||
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
||||
}
|
||||
|
||||
let ast = { type: 'root', input, nodes: [] };
|
||||
let stack = [ast];
|
||||
const ast = { type: 'root', input, nodes: [] };
|
||||
const stack = [ast];
|
||||
let block = ast;
|
||||
let prev = ast;
|
||||
let brackets = 0;
|
||||
let length = input.length;
|
||||
const length = input.length;
|
||||
let index = 0;
|
||||
let depth = 0;
|
||||
let value;
|
||||
let memo = {};
|
||||
|
||||
/**
|
||||
* Helpers
|
||||
@@ -16653,7 +16682,6 @@ const parse = (input, options = {}) => {
|
||||
if (value === CHAR_LEFT_SQUARE_BRACKET) {
|
||||
brackets++;
|
||||
|
||||
let closed = true;
|
||||
let next;
|
||||
|
||||
while (index < length && (next = advance())) {
|
||||
@@ -16709,7 +16737,7 @@ const parse = (input, options = {}) => {
|
||||
*/
|
||||
|
||||
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
||||
let open = value;
|
||||
const open = value;
|
||||
let next;
|
||||
|
||||
if (options.keepQuotes !== true) {
|
||||
@@ -16741,8 +16769,8 @@ const parse = (input, options = {}) => {
|
||||
if (value === CHAR_LEFT_CURLY_BRACE) {
|
||||
depth++;
|
||||
|
||||
let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
||||
let brace = {
|
||||
const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
||||
const brace = {
|
||||
type: 'brace',
|
||||
open: true,
|
||||
close: false,
|
||||
@@ -16769,7 +16797,7 @@ const parse = (input, options = {}) => {
|
||||
continue;
|
||||
}
|
||||
|
||||
let type = 'close';
|
||||
const type = 'close';
|
||||
block = stack.pop();
|
||||
block.close = true;
|
||||
|
||||
@@ -16787,7 +16815,7 @@ const parse = (input, options = {}) => {
|
||||
if (value === CHAR_COMMA && depth > 0) {
|
||||
if (block.ranges > 0) {
|
||||
block.ranges = 0;
|
||||
let open = block.nodes.shift();
|
||||
const open = block.nodes.shift();
|
||||
block.nodes = [open, { type: 'text', value: stringify(block) }];
|
||||
}
|
||||
|
||||
@@ -16801,7 +16829,7 @@ const parse = (input, options = {}) => {
|
||||
*/
|
||||
|
||||
if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
|
||||
let siblings = block.nodes;
|
||||
const siblings = block.nodes;
|
||||
|
||||
if (depth === 0 || siblings.length === 0) {
|
||||
push({ type: 'text', value });
|
||||
@@ -16828,7 +16856,7 @@ const parse = (input, options = {}) => {
|
||||
if (prev.type === 'range') {
|
||||
siblings.pop();
|
||||
|
||||
let before = siblings[siblings.length - 1];
|
||||
const before = siblings[siblings.length - 1];
|
||||
before.value += prev.value + value;
|
||||
prev = before;
|
||||
block.ranges--;
|
||||
@@ -16861,8 +16889,8 @@ const parse = (input, options = {}) => {
|
||||
});
|
||||
|
||||
// get the location of the block on parent.nodes (block's siblings)
|
||||
let parent = stack[stack.length - 1];
|
||||
let index = parent.nodes.indexOf(block);
|
||||
const parent = stack[stack.length - 1];
|
||||
const index = parent.nodes.indexOf(block);
|
||||
// replace the (invalid) block with it's nodes
|
||||
parent.nodes.splice(index, 1, ...block.nodes);
|
||||
}
|
||||
@@ -16886,9 +16914,9 @@ module.exports = parse;
|
||||
const utils = __nccwpck_require__(5207);
|
||||
|
||||
module.exports = (ast, options = {}) => {
|
||||
let stringify = (node, parent = {}) => {
|
||||
let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
||||
let invalidNode = node.invalid === true && options.escapeInvalid === true;
|
||||
const stringify = (node, parent = {}) => {
|
||||
const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
||||
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
||||
let output = '';
|
||||
|
||||
if (node.value) {
|
||||
@@ -16903,7 +16931,7 @@ module.exports = (ast, options = {}) => {
|
||||
}
|
||||
|
||||
if (node.nodes) {
|
||||
for (let child of node.nodes) {
|
||||
for (const child of node.nodes) {
|
||||
output += stringify(child);
|
||||
}
|
||||
}
|
||||
@@ -16954,7 +16982,7 @@ exports.exceedsLimit = (min, max, step = 1, limit) => {
|
||||
*/
|
||||
|
||||
exports.escapeNode = (block, n = 0, type) => {
|
||||
let node = block.nodes[n];
|
||||
const node = block.nodes[n];
|
||||
if (!node) return;
|
||||
|
||||
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
||||
@@ -17023,13 +17051,23 @@ exports.reduce = nodes => nodes.reduce((acc, node) => {
|
||||
|
||||
exports.flatten = (...args) => {
|
||||
const result = [];
|
||||
|
||||
const flat = arr => {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
let ele = arr[i];
|
||||
Array.isArray(ele) ? flat(ele, result) : ele !== void 0 && result.push(ele);
|
||||
const ele = arr[i];
|
||||
|
||||
if (Array.isArray(ele)) {
|
||||
flat(ele);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ele !== undefined) {
|
||||
result.push(ele);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
flat(args);
|
||||
return result;
|
||||
};
|
||||
@@ -17131,7 +17169,7 @@ const toMaxLen = (input, maxLength) => {
|
||||
return negative ? ('-' + input) : input;
|
||||
};
|
||||
|
||||
const toSequence = (parts, options) => {
|
||||
const toSequence = (parts, options, maxLen) => {
|
||||
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
||||
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
||||
|
||||
@@ -17141,11 +17179,11 @@ const toSequence = (parts, options) => {
|
||||
let result;
|
||||
|
||||
if (parts.positives.length) {
|
||||
positives = parts.positives.join('|');
|
||||
positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
|
||||
}
|
||||
|
||||
if (parts.negatives.length) {
|
||||
negatives = `-(${prefix}${parts.negatives.join('|')})`;
|
||||
negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)).join('|')})`;
|
||||
}
|
||||
|
||||
if (positives && negatives) {
|
||||
@@ -17243,7 +17281,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
|
||||
|
||||
if (options.toRegex === true) {
|
||||
return step > 1
|
||||
? toSequence(parts, options)
|
||||
? toSequence(parts, options, maxLen)
|
||||
: toRegex(range, null, { wrap: false, ...options });
|
||||
}
|
||||
|
||||
@@ -17255,7 +17293,6 @@ const fillLetters = (start, end, step = 1, options = {}) => {
|
||||
return invalidRange(start, end, options);
|
||||
}
|
||||
|
||||
|
||||
let format = options.transform || (val => String.fromCharCode(val));
|
||||
let a = `${start}`.charCodeAt(0);
|
||||
let b = `${end}`.charCodeAt(0);
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/licenses.txt
generated
vendored
2
dist/licenses.txt
generated
vendored
@@ -5723,7 +5723,7 @@ braces
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2018, Jon Schlinkert.
|
||||
Copyright (c) 2014-present, Jon Schlinkert.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tj-actions/changed-files",
|
||||
"version": "44.4.0",
|
||||
"version": "44.5.0",
|
||||
"description": "Github action to retrieve all (added, copied, modified, deleted, renamed, type changed, unmerged, unknown) files and directories.",
|
||||
"main": "lib/main.js",
|
||||
"publishConfig": {
|
||||
|
||||
@@ -659,95 +659,45 @@ describe('utils test', () => {
|
||||
})
|
||||
})
|
||||
describe('getPreviousGitTag', () => {
|
||||
// Function returns the second latest tag and its SHA
|
||||
// Function returns the second-latest tag and its SHA
|
||||
it('should return the second latest tag and its SHA when multiple tags are present', async () => {
|
||||
jest
|
||||
.spyOn(exec, 'getExecOutput')
|
||||
.mockResolvedValueOnce({
|
||||
stdout: 'v1.0.1\nv1.0.0\nv0.9.9',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
stdout: 'abc123',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
const result = await getPreviousGitTag({
|
||||
cwd: '.',
|
||||
tagsPattern: '*',
|
||||
tagsIgnorePattern: ''
|
||||
tagsIgnorePattern: '',
|
||||
currentBranch: 'v1.0.1'
|
||||
})
|
||||
expect(result).toEqual({
|
||||
tag: 'v1.0.0',
|
||||
sha: 'f0751de6af436d4e79016e2041cf6400e0833653'
|
||||
})
|
||||
expect(result).toEqual({tag: 'v1.0.0', sha: 'abc123'})
|
||||
})
|
||||
|
||||
// Tags are filtered by a specified pattern when 'tagsPattern' is provided
|
||||
it('should filter tags by the specified pattern', async () => {
|
||||
jest
|
||||
.spyOn(exec, 'getExecOutput')
|
||||
.mockResolvedValueOnce({
|
||||
stdout: 'v1.0.1\nv1.0.0\nv0.9.9',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
stdout: 'def456',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
const result = await getPreviousGitTag({
|
||||
cwd: '.',
|
||||
tagsPattern: 'v1.*',
|
||||
tagsIgnorePattern: ''
|
||||
tagsIgnorePattern: '',
|
||||
currentBranch: 'v1.0.1'
|
||||
})
|
||||
expect(result).toEqual({
|
||||
tag: 'v1.0.0',
|
||||
sha: 'f0751de6af436d4e79016e2041cf6400e0833653'
|
||||
})
|
||||
expect(result).toEqual({tag: 'v1.0.0', sha: 'def456'})
|
||||
})
|
||||
|
||||
// Tags are excluded by a specified ignore pattern when 'tagsIgnorePattern' is provided
|
||||
it('should exclude tags by the specified ignore pattern', async () => {
|
||||
jest
|
||||
.spyOn(exec, 'getExecOutput')
|
||||
.mockResolvedValueOnce({
|
||||
stdout: 'v1.0.1\nv1.0.0\nv0.9.9',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
stdout: 'ghi789',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
const result = await getPreviousGitTag({
|
||||
cwd: '.',
|
||||
tagsPattern: '*',
|
||||
tagsIgnorePattern: 'v0.*.*'
|
||||
tagsIgnorePattern: 'v0.*.*',
|
||||
currentBranch: 'v1.0.1'
|
||||
})
|
||||
expect(result).toEqual({tag: 'v1.0.0', sha: 'ghi789'})
|
||||
})
|
||||
|
||||
// Function executes silently when debug mode is not active
|
||||
it('should execute silently when debug mode is not active', async () => {
|
||||
jest.spyOn(core, 'isDebug').mockReturnValue(false)
|
||||
const spy = jest
|
||||
.spyOn(exec, 'getExecOutput')
|
||||
.mockResolvedValueOnce({
|
||||
stdout: 'v1.0.1\nv1.0.0',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
stdout: 'jkl012',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
await getPreviousGitTag({
|
||||
cwd: '.',
|
||||
tagsPattern: '*',
|
||||
tagsIgnorePattern: ''
|
||||
})
|
||||
expect(spy).toHaveBeenCalledWith('git', ['tag', '--sort=-creatordate'], {
|
||||
cwd: '.',
|
||||
silent: true
|
||||
expect(result).toEqual({
|
||||
tag: 'v1.0.0',
|
||||
sha: 'f0751de6af436d4e79016e2041cf6400e0833653'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -761,7 +711,8 @@ describe('utils test', () => {
|
||||
const result = await getPreviousGitTag({
|
||||
cwd: '.',
|
||||
tagsPattern: '*',
|
||||
tagsIgnorePattern: ''
|
||||
tagsIgnorePattern: '',
|
||||
currentBranch: ''
|
||||
})
|
||||
expect(result).toEqual({tag: '', sha: ''})
|
||||
})
|
||||
@@ -769,44 +720,16 @@ describe('utils test', () => {
|
||||
// Only one tag is available, making it impossible to find a previous tag
|
||||
it('should return empty values when only one tag is available', async () => {
|
||||
jest.spyOn(exec, 'getExecOutput').mockResolvedValueOnce({
|
||||
stdout: 'v1.0.1',
|
||||
stdout:
|
||||
'v1.0.1|f0751de6af436d4e79016e2041cf6400e0833653|2021-01-01T00:00:00Z',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
const result = await getPreviousGitTag({
|
||||
cwd: '.',
|
||||
tagsPattern: '*',
|
||||
tagsIgnorePattern: ''
|
||||
})
|
||||
expect(result).toEqual({tag: '', sha: ''})
|
||||
})
|
||||
|
||||
// Provided 'tagsPattern' matches no tags
|
||||
it('should return empty values when provided tagsPattern matches no tags', async () => {
|
||||
jest.spyOn(exec, 'getExecOutput').mockResolvedValueOnce({
|
||||
stdout: 'v1.0.1\nv1.0.0',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
const result = await getPreviousGitTag({
|
||||
cwd: '.',
|
||||
tagsPattern: 'nonexistent*',
|
||||
tagsIgnorePattern: ''
|
||||
})
|
||||
expect(result).toEqual({tag: '', sha: ''})
|
||||
})
|
||||
|
||||
// Provided 'tagsIgnorePattern' excludes all tags
|
||||
it('should return empty values when provided tagsIgnorePattern excludes all tags', async () => {
|
||||
jest.spyOn(exec, 'getExecOutput').mockResolvedValueOnce({
|
||||
stdout: 'v1.0.1\nv1.0.0',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
const result = await getPreviousGitTag({
|
||||
cwd: '.',
|
||||
tagsPattern: '*',
|
||||
tagsIgnorePattern: 'v*'
|
||||
tagsIgnorePattern: '',
|
||||
currentBranch: 'v1.0.1'
|
||||
})
|
||||
expect(result).toEqual({tag: '', sha: ''})
|
||||
})
|
||||
@@ -817,34 +740,13 @@ describe('utils test', () => {
|
||||
.spyOn(exec, 'getExecOutput')
|
||||
.mockRejectedValue(new Error('git command failed'))
|
||||
await expect(
|
||||
getPreviousGitTag({cwd: '.', tagsPattern: '*', tagsIgnorePattern: ''})
|
||||
getPreviousGitTag({
|
||||
cwd: '.',
|
||||
tagsPattern: '*',
|
||||
tagsIgnorePattern: '',
|
||||
currentBranch: 'v1.0.1'
|
||||
})
|
||||
).rejects.toThrow('git command failed')
|
||||
})
|
||||
|
||||
// Debug mode logs additional information
|
||||
it('should log additional information when debug mode is active', async () => {
|
||||
jest.spyOn(core, 'isDebug').mockReturnValue(true)
|
||||
const spy = jest
|
||||
.spyOn(exec, 'getExecOutput')
|
||||
.mockResolvedValueOnce({
|
||||
stdout: 'v1.0.1\nv1.0.0',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
stdout: 'mno345',
|
||||
stderr: '',
|
||||
exitCode: 0
|
||||
})
|
||||
await getPreviousGitTag({
|
||||
cwd: '.',
|
||||
tagsPattern: '*',
|
||||
tagsIgnorePattern: ''
|
||||
})
|
||||
expect(spy).toHaveBeenCalledWith('git', ['tag', '--sort=-creatordate'], {
|
||||
cwd: '.',
|
||||
silent: false
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -243,7 +243,8 @@ export const getSHAForNonPullRequestEvent = async ({
|
||||
const {sha, tag} = await getPreviousGitTag({
|
||||
cwd: workingDirectory,
|
||||
tagsPattern: inputs.tagsPattern,
|
||||
tagsIgnorePattern: inputs.tagsIgnorePattern
|
||||
tagsIgnorePattern: inputs.tagsIgnorePattern,
|
||||
currentBranch
|
||||
})
|
||||
previousSha = sha
|
||||
targetBranch = tag
|
||||
|
||||
75
src/utils.ts
75
src/utils.ts
@@ -831,53 +831,80 @@ export const cleanShaInput = async ({
|
||||
|
||||
return stdout.trim()
|
||||
}
|
||||
|
||||
export const getPreviousGitTag = async ({
|
||||
cwd,
|
||||
tagsPattern,
|
||||
currentBranch,
|
||||
tagsIgnorePattern
|
||||
}: {
|
||||
cwd: string
|
||||
tagsPattern: string
|
||||
currentBranch: string
|
||||
tagsIgnorePattern?: string
|
||||
}): Promise<{tag: string; sha: string}> => {
|
||||
const ignorePatterns: string[] = []
|
||||
let currentShaDate: Date | null = null
|
||||
|
||||
const {stdout} = await exec.getExecOutput(
|
||||
'git',
|
||||
['tag', '--sort=-creatordate'],
|
||||
[
|
||||
'tag',
|
||||
'--sort=-creatordate',
|
||||
'--format=%(refname:short)|%(objectname)|%(creatordate:iso)'
|
||||
],
|
||||
{
|
||||
cwd,
|
||||
silent: !core.isDebug()
|
||||
}
|
||||
)
|
||||
|
||||
let tags = stdout.trim().split('\n')
|
||||
|
||||
if (tagsPattern) {
|
||||
tags = tags.filter(tag => mm.isMatch(tag, tagsPattern))
|
||||
}
|
||||
|
||||
if (tagsIgnorePattern) {
|
||||
tags = tags.filter(tag => !mm.isMatch(tag, tagsIgnorePattern))
|
||||
ignorePatterns.push(tagsIgnorePattern)
|
||||
}
|
||||
|
||||
if (tags.length < 2) {
|
||||
core.warning('No previous tag found')
|
||||
return {tag: '', sha: ''}
|
||||
}
|
||||
|
||||
const previousTag = tags[1]
|
||||
|
||||
const {stdout: stdout2} = await exec.getExecOutput(
|
||||
'git',
|
||||
['rev-parse', previousTag],
|
||||
{
|
||||
cwd,
|
||||
silent: !core.isDebug()
|
||||
if (currentBranch) {
|
||||
ignorePatterns.push(currentBranch)
|
||||
try {
|
||||
const {stdout: currentShaDateOutput} = await exec.getExecOutput(
|
||||
'git',
|
||||
['show', '-s', '--format=%ai', currentBranch],
|
||||
{
|
||||
cwd,
|
||||
silent: !core.isDebug()
|
||||
}
|
||||
)
|
||||
currentShaDate = new Date(currentShaDateOutput.trim())
|
||||
} catch (error) {
|
||||
// Handle the case where the current branch doesn't exist
|
||||
// This might happen in detached head state
|
||||
core.warning(`Failed to get date for current branch ${currentBranch}`)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const sha = stdout2.trim()
|
||||
const previousTag: {tag: string; sha: string} = {tag: '', sha: ''}
|
||||
|
||||
return {tag: previousTag, sha}
|
||||
const tags = stdout.trim().split('\n')
|
||||
for (const tagData of tags) {
|
||||
const [tag, sha, dateString] = tagData.split('|')
|
||||
if (!mm.isMatch(tag, tagsPattern) || mm.isMatch(tag, ignorePatterns)) {
|
||||
continue
|
||||
}
|
||||
const date = new Date(dateString)
|
||||
if (currentShaDate && date >= currentShaDate) {
|
||||
continue
|
||||
}
|
||||
// Found a suitable tag, no need to continue
|
||||
previousTag.tag = tag
|
||||
previousTag.sha = sha
|
||||
break
|
||||
}
|
||||
|
||||
if (!previousTag.tag) {
|
||||
core.warning('No previous tag found')
|
||||
}
|
||||
|
||||
return previousTag
|
||||
}
|
||||
|
||||
export const canDiffCommits = async ({
|
||||
|
||||
32
yarn.lock
32
yarn.lock
@@ -1553,12 +1553,12 @@ brace-expansion@^2.0.1:
|
||||
dependencies:
|
||||
balanced-match "^1.0.0"
|
||||
|
||||
braces@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
|
||||
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
|
||||
braces@^3.0.3:
|
||||
version "3.0.3"
|
||||
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
|
||||
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
|
||||
dependencies:
|
||||
fill-range "^7.0.1"
|
||||
fill-range "^7.1.1"
|
||||
|
||||
browserslist@^4.21.0, browserslist@^4.22.2:
|
||||
version "4.23.0"
|
||||
@@ -2332,10 +2332,10 @@ file-entry-cache@^6.0.1:
|
||||
dependencies:
|
||||
flat-cache "^3.0.4"
|
||||
|
||||
fill-range@^7.0.1:
|
||||
version "7.0.1"
|
||||
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
|
||||
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
|
||||
fill-range@^7.1.1:
|
||||
version "7.1.1"
|
||||
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
|
||||
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
|
||||
dependencies:
|
||||
to-regex-range "^5.0.1"
|
||||
|
||||
@@ -3442,11 +3442,11 @@ merge2@^1.3.0, merge2@^1.4.1:
|
||||
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
|
||||
|
||||
micromatch@^4.0.4, micromatch@^4.0.5:
|
||||
version "4.0.5"
|
||||
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
|
||||
integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==
|
||||
version "4.0.7"
|
||||
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.7.tgz#33e8190d9fe474a9895525f5618eee136d46c2e5"
|
||||
integrity sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==
|
||||
dependencies:
|
||||
braces "^3.0.2"
|
||||
braces "^3.0.3"
|
||||
picomatch "^2.3.1"
|
||||
|
||||
mimic-fn@^2.1.0:
|
||||
@@ -4093,9 +4093,9 @@ ts-api-utils@^1.3.0:
|
||||
integrity sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==
|
||||
|
||||
ts-jest@^29.1.0:
|
||||
version "29.1.2"
|
||||
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.1.2.tgz#7613d8c81c43c8cb312c6904027257e814c40e09"
|
||||
integrity sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==
|
||||
version "29.1.3"
|
||||
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.1.3.tgz#2bab16ba5ab0f4896684985f9618acc2cf1197e9"
|
||||
integrity sha512-6L9qz3ginTd1NKhOxmkP0qU3FyKjj5CPoY+anszfVn6Pmv/RIKzhiMCsH7Yb7UvJR9I2A64rm4zQl531s2F1iw==
|
||||
dependencies:
|
||||
bs-logger "0.x"
|
||||
fast-json-stable-stringify "2.x"
|
||||
|
||||
Reference in New Issue
Block a user