feat: add support for providing patterns to match tags (#2098)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
5f0139347a
commit
03c184259a
@ -235,6 +235,15 @@ inputs:
|
|||||||
description: "Use POSIX path separator `/` for output file paths on Windows."
|
description: "Use POSIX path separator `/` for output file paths on Windows."
|
||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
|
tags_pattern:
|
||||||
|
description: "Tags pattern to include."
|
||||||
|
required: false
|
||||||
|
default: "*"
|
||||||
|
tags_ignore_pattern:
|
||||||
|
description: "Tags pattern to ignore."
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
added_files:
|
added_files:
|
||||||
|
30
dist/index.js
generated
vendored
30
dist/index.js
generated
vendored
@ -1055,7 +1055,11 @@ const getSHAForNonPullRequestEvent = (_j) => __awaiter(void 0, [_j], void 0, fun
|
|||||||
}
|
}
|
||||||
else if (isTag) {
|
else if (isTag) {
|
||||||
core.debug('Getting previous SHA for tag...');
|
core.debug('Getting previous SHA for tag...');
|
||||||
const { sha, tag } = yield (0, utils_1.getPreviousGitTag)({ cwd: workingDirectory });
|
const { sha, tag } = yield (0, utils_1.getPreviousGitTag)({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
tagsPattern: inputs.tagsPattern,
|
||||||
|
tagsIgnorePattern: inputs.tagsIgnorePattern
|
||||||
|
});
|
||||||
previousSha = sha;
|
previousSha = sha;
|
||||||
targetBranch = tag;
|
targetBranch = tag;
|
||||||
}
|
}
|
||||||
@ -1388,7 +1392,9 @@ exports.DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS = {
|
|||||||
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false,
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false,
|
||||||
excludeSubmodules: false,
|
excludeSubmodules: false,
|
||||||
fetchMissingHistoryMaxRetries: 10,
|
fetchMissingHistoryMaxRetries: 10,
|
||||||
usePosixPathSeparator: false
|
usePosixPathSeparator: false,
|
||||||
|
tagsPattern: '*',
|
||||||
|
tagsIgnorePattern: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1610,6 +1616,14 @@ const getInputs = () => {
|
|||||||
const usePosixPathSeparator = core.getBooleanInput('use_posix_path_separator', {
|
const usePosixPathSeparator = core.getBooleanInput('use_posix_path_separator', {
|
||||||
required: false
|
required: false
|
||||||
});
|
});
|
||||||
|
const tagsPattern = core.getInput('tags_pattern', {
|
||||||
|
required: false,
|
||||||
|
trimWhitespace: false
|
||||||
|
});
|
||||||
|
const tagsIgnorePattern = core.getInput('tags_ignore_pattern', {
|
||||||
|
required: false,
|
||||||
|
trimWhitespace: false
|
||||||
|
});
|
||||||
const inputs = {
|
const inputs = {
|
||||||
files,
|
files,
|
||||||
filesSeparator,
|
filesSeparator,
|
||||||
@ -1651,6 +1665,8 @@ const getInputs = () => {
|
|||||||
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
||||||
excludeSubmodules,
|
excludeSubmodules,
|
||||||
usePosixPathSeparator,
|
usePosixPathSeparator,
|
||||||
|
tagsPattern,
|
||||||
|
tagsIgnorePattern,
|
||||||
// End Not Supported via REST API
|
// End Not Supported via REST API
|
||||||
dirNames,
|
dirNames,
|
||||||
dirNamesExcludeCurrentDir,
|
dirNamesExcludeCurrentDir,
|
||||||
@ -2604,12 +2620,18 @@ const cleanShaInput = (_5) => __awaiter(void 0, [_5], void 0, function* ({ sha,
|
|||||||
return stdout.trim();
|
return stdout.trim();
|
||||||
});
|
});
|
||||||
exports.cleanShaInput = cleanShaInput;
|
exports.cleanShaInput = cleanShaInput;
|
||||||
const getPreviousGitTag = (_6) => __awaiter(void 0, [_6], void 0, function* ({ cwd }) {
|
const getPreviousGitTag = (_6) => __awaiter(void 0, [_6], void 0, function* ({ cwd, tagsPattern, tagsIgnorePattern }) {
|
||||||
const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-creatordate'], {
|
const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-creatordate'], {
|
||||||
cwd,
|
cwd,
|
||||||
silent: !core.isDebug()
|
silent: !core.isDebug()
|
||||||
});
|
});
|
||||||
const tags = stdout.trim().split('\n');
|
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));
|
||||||
|
}
|
||||||
if (tags.length < 2) {
|
if (tags.length < 2) {
|
||||||
core.warning('No previous tag found');
|
core.warning('No previous tag found');
|
||||||
return { tag: '', sha: '' };
|
return { tag: '', sha: '' };
|
||||||
|
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
@ -53,6 +53,8 @@ exports[`getInputs should correctly parse boolean inputs 1`] = `
|
|||||||
"since": "",
|
"since": "",
|
||||||
"sinceLastRemoteCommit": "false",
|
"sinceLastRemoteCommit": "false",
|
||||||
"skipInitialFetch": "true",
|
"skipInitialFetch": "true",
|
||||||
|
"tagsIgnorePattern": "",
|
||||||
|
"tagsPattern": "*",
|
||||||
"token": "",
|
"token": "",
|
||||||
"until": "",
|
"until": "",
|
||||||
"usePosixPathSeparator": "false",
|
"usePosixPathSeparator": "false",
|
||||||
@ -113,6 +115,8 @@ exports[`getInputs should correctly parse numeric inputs 1`] = `
|
|||||||
"since": "",
|
"since": "",
|
||||||
"sinceLastRemoteCommit": false,
|
"sinceLastRemoteCommit": false,
|
||||||
"skipInitialFetch": false,
|
"skipInitialFetch": false,
|
||||||
|
"tagsIgnorePattern": "",
|
||||||
|
"tagsPattern": "",
|
||||||
"token": "",
|
"token": "",
|
||||||
"until": "",
|
"until": "",
|
||||||
"usePosixPathSeparator": false,
|
"usePosixPathSeparator": false,
|
||||||
@ -171,6 +175,8 @@ exports[`getInputs should correctly parse string inputs 1`] = `
|
|||||||
"since": "",
|
"since": "",
|
||||||
"sinceLastRemoteCommit": false,
|
"sinceLastRemoteCommit": false,
|
||||||
"skipInitialFetch": false,
|
"skipInitialFetch": false,
|
||||||
|
"tagsIgnorePattern": "",
|
||||||
|
"tagsPattern": "",
|
||||||
"token": "token",
|
"token": "token",
|
||||||
"until": "",
|
"until": "",
|
||||||
"usePosixPathSeparator": false,
|
"usePosixPathSeparator": false,
|
||||||
@ -231,6 +237,8 @@ exports[`getInputs should handle invalid numeric inputs correctly 1`] = `
|
|||||||
"since": "",
|
"since": "",
|
||||||
"sinceLastRemoteCommit": false,
|
"sinceLastRemoteCommit": false,
|
||||||
"skipInitialFetch": false,
|
"skipInitialFetch": false,
|
||||||
|
"tagsIgnorePattern": "",
|
||||||
|
"tagsPattern": "",
|
||||||
"token": "",
|
"token": "",
|
||||||
"until": "",
|
"until": "",
|
||||||
"usePosixPathSeparator": false,
|
"usePosixPathSeparator": false,
|
||||||
@ -291,6 +299,8 @@ exports[`getInputs should handle negative numeric inputs correctly 1`] = `
|
|||||||
"since": "",
|
"since": "",
|
||||||
"sinceLastRemoteCommit": false,
|
"sinceLastRemoteCommit": false,
|
||||||
"skipInitialFetch": false,
|
"skipInitialFetch": false,
|
||||||
|
"tagsIgnorePattern": "",
|
||||||
|
"tagsPattern": "",
|
||||||
"token": "",
|
"token": "",
|
||||||
"until": "",
|
"until": "",
|
||||||
"usePosixPathSeparator": false,
|
"usePosixPathSeparator": false,
|
||||||
@ -352,6 +362,8 @@ exports[`getInputs should return default values when no inputs are provided 1`]
|
|||||||
"since": "",
|
"since": "",
|
||||||
"sinceLastRemoteCommit": false,
|
"sinceLastRemoteCommit": false,
|
||||||
"skipInitialFetch": false,
|
"skipInitialFetch": false,
|
||||||
|
"tagsIgnorePattern": "",
|
||||||
|
"tagsPattern": "*",
|
||||||
"token": "",
|
"token": "",
|
||||||
"until": "",
|
"until": "",
|
||||||
"usePosixPathSeparator": false,
|
"usePosixPathSeparator": false,
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import * as exec from '@actions/exec'
|
||||||
import {ChangeTypeEnum} from '../changedFiles'
|
import {ChangeTypeEnum} from '../changedFiles'
|
||||||
import {Inputs} from '../inputs'
|
import {Inputs} from '../inputs'
|
||||||
import {
|
import {
|
||||||
getDirname,
|
getDirname,
|
||||||
getDirnameMaxDepth,
|
getDirnameMaxDepth,
|
||||||
getFilteredChangedFiles,
|
getFilteredChangedFiles,
|
||||||
|
getPreviousGitTag,
|
||||||
normalizeSeparators,
|
normalizeSeparators,
|
||||||
warnUnsupportedRESTAPIInputs
|
warnUnsupportedRESTAPIInputs
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
@ -638,7 +640,9 @@ describe('utils test', () => {
|
|||||||
useRestApi: false,
|
useRestApi: false,
|
||||||
excludeSubmodules: false,
|
excludeSubmodules: false,
|
||||||
fetchMissingHistoryMaxRetries: 10,
|
fetchMissingHistoryMaxRetries: 10,
|
||||||
usePosixPathSeparator: false
|
usePosixPathSeparator: false,
|
||||||
|
tagsPattern: '*',
|
||||||
|
tagsIgnorePattern: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const coreWarningSpy = jest.spyOn(core, 'warning')
|
const coreWarningSpy = jest.spyOn(core, 'warning')
|
||||||
@ -654,4 +658,193 @@ describe('utils test', () => {
|
|||||||
expect(coreWarningSpy).toHaveBeenCalledTimes(1)
|
expect(coreWarningSpy).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
describe('getPreviousGitTag', () => {
|
||||||
|
// 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: ''
|
||||||
|
})
|
||||||
|
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: ''
|
||||||
|
})
|
||||||
|
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.*.*'
|
||||||
|
})
|
||||||
|
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
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// No tags are available in the repository
|
||||||
|
it('should return empty values when no tags are available in the repository', async () => {
|
||||||
|
jest.spyOn(exec, 'getExecOutput').mockResolvedValueOnce({
|
||||||
|
stdout: '',
|
||||||
|
stderr: '',
|
||||||
|
exitCode: 0
|
||||||
|
})
|
||||||
|
const result = await getPreviousGitTag({
|
||||||
|
cwd: '.',
|
||||||
|
tagsPattern: '*',
|
||||||
|
tagsIgnorePattern: ''
|
||||||
|
})
|
||||||
|
expect(result).toEqual({tag: '', sha: ''})
|
||||||
|
})
|
||||||
|
|
||||||
|
// 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',
|
||||||
|
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*'
|
||||||
|
})
|
||||||
|
expect(result).toEqual({tag: '', sha: ''})
|
||||||
|
})
|
||||||
|
|
||||||
|
// Git commands fail and throw errors
|
||||||
|
it('should throw an error when git commands fail', async () => {
|
||||||
|
jest
|
||||||
|
.spyOn(exec, 'getExecOutput')
|
||||||
|
.mockRejectedValue(new Error('git command failed'))
|
||||||
|
await expect(
|
||||||
|
getPreviousGitTag({cwd: '.', tagsPattern: '*', tagsIgnorePattern: ''})
|
||||||
|
).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
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -240,7 +240,11 @@ export const getSHAForNonPullRequestEvent = async ({
|
|||||||
}
|
}
|
||||||
} else if (isTag) {
|
} else if (isTag) {
|
||||||
core.debug('Getting previous SHA for tag...')
|
core.debug('Getting previous SHA for tag...')
|
||||||
const {sha, tag} = await getPreviousGitTag({cwd: workingDirectory})
|
const {sha, tag} = await getPreviousGitTag({
|
||||||
|
cwd: workingDirectory,
|
||||||
|
tagsPattern: inputs.tagsPattern,
|
||||||
|
tagsIgnorePattern: inputs.tagsIgnorePattern
|
||||||
|
})
|
||||||
previousSha = sha
|
previousSha = sha
|
||||||
targetBranch = tag
|
targetBranch = tag
|
||||||
} else {
|
} else {
|
||||||
|
@ -23,5 +23,7 @@ export const DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS: Partial<Inputs> = {
|
|||||||
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false,
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs: false,
|
||||||
excludeSubmodules: false,
|
excludeSubmodules: false,
|
||||||
fetchMissingHistoryMaxRetries: 10,
|
fetchMissingHistoryMaxRetries: 10,
|
||||||
usePosixPathSeparator: false
|
usePosixPathSeparator: false,
|
||||||
|
tagsPattern: '*',
|
||||||
|
tagsIgnorePattern: ''
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,8 @@ export type Inputs = {
|
|||||||
excludeSubmodules: boolean
|
excludeSubmodules: boolean
|
||||||
fetchMissingHistoryMaxRetries?: number
|
fetchMissingHistoryMaxRetries?: number
|
||||||
usePosixPathSeparator: boolean
|
usePosixPathSeparator: boolean
|
||||||
|
tagsPattern: string
|
||||||
|
tagsIgnorePattern?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getInputs = (): Inputs => {
|
export const getInputs = (): Inputs => {
|
||||||
@ -259,6 +261,15 @@ export const getInputs = (): Inputs => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const tagsPattern = core.getInput('tags_pattern', {
|
||||||
|
required: false,
|
||||||
|
trimWhitespace: false
|
||||||
|
})
|
||||||
|
const tagsIgnorePattern = core.getInput('tags_ignore_pattern', {
|
||||||
|
required: false,
|
||||||
|
trimWhitespace: false
|
||||||
|
})
|
||||||
|
|
||||||
const inputs: Inputs = {
|
const inputs: Inputs = {
|
||||||
files,
|
files,
|
||||||
filesSeparator,
|
filesSeparator,
|
||||||
@ -300,6 +311,8 @@ export const getInputs = (): Inputs => {
|
|||||||
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
dirNamesDeletedFilesIncludeOnlyDeletedDirs,
|
||||||
excludeSubmodules,
|
excludeSubmodules,
|
||||||
usePosixPathSeparator,
|
usePosixPathSeparator,
|
||||||
|
tagsPattern,
|
||||||
|
tagsIgnorePattern,
|
||||||
// End Not Supported via REST API
|
// End Not Supported via REST API
|
||||||
dirNames,
|
dirNames,
|
||||||
dirNamesExcludeCurrentDir,
|
dirNamesExcludeCurrentDir,
|
||||||
|
16
src/utils.ts
16
src/utils.ts
@ -832,9 +832,13 @@ export const cleanShaInput = async ({
|
|||||||
return stdout.trim()
|
return stdout.trim()
|
||||||
}
|
}
|
||||||
export const getPreviousGitTag = async ({
|
export const getPreviousGitTag = async ({
|
||||||
cwd
|
cwd,
|
||||||
|
tagsPattern,
|
||||||
|
tagsIgnorePattern
|
||||||
}: {
|
}: {
|
||||||
cwd: string
|
cwd: string
|
||||||
|
tagsPattern: string
|
||||||
|
tagsIgnorePattern?: string
|
||||||
}): Promise<{tag: string; sha: string}> => {
|
}): Promise<{tag: string; sha: string}> => {
|
||||||
const {stdout} = await exec.getExecOutput(
|
const {stdout} = await exec.getExecOutput(
|
||||||
'git',
|
'git',
|
||||||
@ -845,7 +849,15 @@ export const getPreviousGitTag = async ({
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const tags = stdout.trim().split('\n')
|
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))
|
||||||
|
}
|
||||||
|
|
||||||
if (tags.length < 2) {
|
if (tags.length < 2) {
|
||||||
core.warning('No previous tag found')
|
core.warning('No previous tag found')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user