Compare commits

...

5 Commits

Author SHA1 Message Date
Tonye Jack
abef388dd9 fix: update test to include push event (#1173)
Co-authored-by: tj-actions[bot] <109116665+tj-actions-bot@users.noreply.github.com>
Co-authored-by: GitHub Action <action@github.com>
2023-05-25 17:39:26 -06:00
Tonye Jack
30e1bb07d4 Fixed bug retrieving older commits 2023-05-25 17:16:16 -06:00
Tonye Jack
9fdfe4cf16 fix: bug with retrieving submodules (#1172) 2023-05-25 15:53:58 -06:00
Tonye Jack
024242fc77 fix: bug with retrieving submodules (#1171) 2023-05-25 15:43:31 -06:00
tj-actions[bot]
ecdfb9c92e Upgraded to v36.0.1 (#1170)
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
2023-05-25 21:42:31 +00:00
8 changed files with 122 additions and 118 deletions

View File

@@ -26,7 +26,6 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event_name != 'push'
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@@ -50,6 +49,7 @@ jobs:
- name: Run eslint on changed files - name: Run eslint on changed files
uses: tj-actions/eslint-changed-files@v18 uses: tj-actions/eslint-changed-files@v18
if: github.event_name != 'push'
with: with:
token: ${{ secrets.PAT_TOKEN }} token: ${{ secrets.PAT_TOKEN }}
config_path: ".eslintrc.json" config_path: ".eslintrc.json"
@@ -62,13 +62,14 @@ jobs:
- name: Verify Changed files - name: Verify Changed files
uses: tj-actions/verify-changed-files@v14 uses: tj-actions/verify-changed-files@v14
id: changed_files id: changed_files
if: github.event_name != 'push'
with: with:
files: | files: |
src src
dist dist
- name: Commit files - name: Commit files
if: steps.changed_files.outputs.files_changed == 'true' if: steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'push'
run: | run: |
git config --local user.email "action@github.com" git config --local user.email "action@github.com"
git config --local user.name "GitHub Action" git config --local user.name "GitHub Action"
@@ -76,7 +77,7 @@ jobs:
git commit -m "Added missing changes and modified dist assets." git commit -m "Added missing changes and modified dist assets."
- name: Push changes - name: Push changes
if: steps.changed_files.outputs.files_changed == 'true' if: steps.changed_files.outputs.files_changed == 'true' && github.event_name == 'pull_request'
uses: ad-m/github-push-action@master uses: ad-m/github-push-action@master
with: with:
github_token: ${{ secrets.PAT_TOKEN }} github_token: ${{ secrets.PAT_TOKEN }}
@@ -1160,7 +1161,7 @@ jobs:
main-branch-name: ${{ steps.branch-name.outputs.base_ref_branch }} main-branch-name: ${{ steps.branch-name.outputs.base_ref_branch }}
workflow-id: 'test.yml' workflow-id: 'test.yml'
- name: Run changed-files with a custom base sha - name: Run changed-files with a custom base sha
if: github.event_name == 'pull_request' && github.event.action != 'closed' && matrix.fetch-depth == 0 if: github.event_name != 'push' && github.event.action != 'closed' && matrix.fetch-depth == 0
id: changed-files-custom-base-sha id: changed-files-custom-base-sha
uses: ./ uses: ./
with: with:

View File

@@ -1,5 +1,17 @@
# Changelog # Changelog
# [36.0.1](https://github.com/tj-actions/changed-files/compare/v36.0.0...v36.0.1) - (2023-05-25)
## <!-- 1 -->🐛 Bug Fixes
- Bug with retrieving submodules ([#1169](https://github.com/tj-actions/changed-files/issues/1169)) ([1c2673b](https://github.com/tj-actions/changed-files/commit/1c2673b763ea086acd660dd4257c9be06eb77667)) - (Tonye Jack)
## <!-- 9 -->⬆️ Upgrades
- Upgraded to v36 ([#1168](https://github.com/tj-actions/changed-files/issues/1168))
Co-authored-by: jackton1 <jackton1@users.noreply.github.com> ([4e23a96](https://github.com/tj-actions/changed-files/commit/4e23a965c8abd6dfe7edc6d9f5523ebde932507d)) - (tj-actions[bot])
# [36.0.0](https://github.com/tj-actions/changed-files/compare/v35.9.2...v36.0.0) - (2023-05-25) # [36.0.0](https://github.com/tj-actions/changed-files/compare/v35.9.2...v36.0.0) - (2023-05-25)
## <!-- 0 -->🚀 Features ## <!-- 0 -->🚀 Features

95
dist/index.js generated vendored
View File

@@ -181,8 +181,7 @@ const getCurrentSHA = ({ inputs, workingDirectory }) => __awaiter(void 0, void 0
currentSha = yield (0, utils_1.gitLog)({ currentSha = yield (0, utils_1.gitLog)({
cwd: workingDirectory, cwd: workingDirectory,
args: [ args: [
'--format', '--format=%H',
'"%H"',
'-n', '-n',
'1', '1',
'--date', '--date',
@@ -207,7 +206,7 @@ const getCurrentSHA = ({ inputs, workingDirectory }) => __awaiter(void 0, void 0
return currentSha; return currentSha;
}); });
const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodule, gitExtraArgs, isTag) => __awaiter(void 0, void 0, void 0, function* () { const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodule, gitExtraArgs, isTag) => __awaiter(void 0, void 0, void 0, function* () {
let targetBranch = env.GITHUB_REFNAME; let targetBranch = env.GITHUB_REF_NAME;
const currentBranch = targetBranch; const currentBranch = targetBranch;
let initialCommit = false; let initialCommit = false;
if (isShallow) { if (isShallow) {
@@ -275,19 +274,14 @@ const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodu
if (inputs.since) { if (inputs.since) {
core.debug(`Getting base SHA for '${inputs.since}'...`); core.debug(`Getting base SHA for '${inputs.since}'...`);
try { try {
previousSha = yield (0, utils_1.gitLog)({ const allCommitsFrom = yield (0, utils_1.gitLog)({
cwd: workingDirectory, cwd: workingDirectory,
args: [ args: ['--format=%H', '--date', 'local', '--since', inputs.since]
'--format',
'"%H"',
'-n',
'1',
'--date',
'local',
'--since',
inputs.since
]
}); });
if (allCommitsFrom) {
const allCommitsFromArray = allCommitsFrom.split('\n');
previousSha = allCommitsFromArray[allCommitsFromArray.length - 1];
}
} }
catch (error) { catch (error) {
core.error(`Invalid since date: ${inputs.since}. ${error.message}`); core.error(`Invalid since date: ${inputs.since}. ${error.message}`);
@@ -301,31 +295,31 @@ const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodu
targetBranch = tag; targetBranch = tag;
} }
else { else {
if (inputs.sinceLastRemoteCommit) {
core.debug('Getting previous SHA for last remote commit...'); core.debug('Getting previous SHA for last remote commit...');
if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) { if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) {
previousSha = env.GITHUB_EVENT_BEFORE; previousSha = env.GITHUB_EVENT_BEFORE;
} }
else { else {
previousSha = yield (0, utils_1.getParentHeadSha)({ cwd: workingDirectory }); previousSha = yield (0, utils_1.getParentSha)({
} cwd: workingDirectory
} });
else {
core.debug('Getting previous SHA for last commit...');
previousSha = yield (0, utils_1.getParentHeadSha)({ cwd: workingDirectory });
} }
if (!previousSha || if (!previousSha ||
previousSha === '0000000000000000000000000000000000000000') { previousSha === '0000000000000000000000000000000000000000') {
previousSha = yield (0, utils_1.getParentHeadSha)({ cwd: workingDirectory }); previousSha = yield (0, utils_1.getParentSha)({
cwd: workingDirectory
});
} }
if (previousSha === currentSha) { if (previousSha === currentSha) {
if (!(yield (0, utils_1.getParentHeadSha)({ cwd: workingDirectory }))) { if (!(yield (0, utils_1.getParentSha)({ cwd: workingDirectory }))) {
core.warning('Initial commit detected no previous commit found.'); core.warning('Initial commit detected no previous commit found.');
initialCommit = true; initialCommit = true;
previousSha = currentSha; previousSha = currentSha;
} }
else { else {
previousSha = yield (0, utils_1.getParentHeadSha)({ cwd: workingDirectory }); previousSha = yield (0, utils_1.getParentSha)({
cwd: workingDirectory
});
} }
} }
else { else {
@@ -591,7 +585,7 @@ const getEnv = () => __awaiter(void 0, void 0, void 0, function* () {
GITHUB_EVENT_PULL_REQUEST_NUMBER: ((_f = eventJson.pull_request) === null || _f === void 0 ? void 0 : _f.number) || '', GITHUB_EVENT_PULL_REQUEST_NUMBER: ((_f = eventJson.pull_request) === null || _f === void 0 ? void 0 : _f.number) || '',
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ((_h = (_g = eventJson.pull_request) === null || _g === void 0 ? void 0 : _g.base) === null || _h === void 0 ? void 0 : _h.sha) || '', GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ((_h = (_g = eventJson.pull_request) === null || _g === void 0 ? void 0 : _g.base) === null || _h === void 0 ? void 0 : _h.sha) || '',
GITHUB_EVENT_FORCED: eventJson.forced || '', GITHUB_EVENT_FORCED: eventJson.forced || '',
GITHUB_REFNAME: process.env.GITHUB_REFNAME || '', GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || '',
GITHUB_REF: process.env.GITHUB_REF || '', GITHUB_REF: process.env.GITHUB_REF || '',
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || '' GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || ''
}; };
@@ -808,9 +802,10 @@ function run() {
const hasSubmodule = yield (0, utils_1.submoduleExists)({ cwd: workingDirectory }); const hasSubmodule = yield (0, utils_1.submoduleExists)({ cwd: workingDirectory });
let gitExtraArgs = ['--no-tags', '--prune', '--recurse-submodules']; let gitExtraArgs = ['--no-tags', '--prune', '--recurse-submodules'];
const isTag = (_a = env.GITHUB_REF) === null || _a === void 0 ? void 0 : _a.startsWith('refs/tags/'); const isTag = (_a = env.GITHUB_REF) === null || _a === void 0 ? void 0 : _a.startsWith('refs/tags/');
const submodulePaths = yield (0, utils_1.getSubmodulePath)({ let submodulePaths = [];
cwd: workingDirectory if (hasSubmodule) {
}); submodulePaths = yield (0, utils_1.getSubmodulePath)({ cwd: workingDirectory });
}
if (isTag) { if (isTag) {
gitExtraArgs = ['--prune', '--no-recurse-submodules']; gitExtraArgs = ['--prune', '--no-recurse-submodules'];
} }
@@ -1165,7 +1160,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.setOutput = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentHeadSha = exports.gitLsRemote = exports.getHeadSha = exports.gitLog = exports.gitDiff = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0; exports.setOutput = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.gitLsRemote = exports.getHeadSha = exports.gitLog = exports.gitDiff = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0;
/*global AsyncIterableIterator*/ /*global AsyncIterableIterator*/
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514)); const exec = __importStar(__nccwpck_require__(1514));
@@ -1239,7 +1234,7 @@ const versionToNumber = (version) => {
return major * 1000000 + minor * 1000 + patch; return major * 1000000 + minor * 1000 + patch;
}; };
const verifyMinimumGitVersion = () => __awaiter(void 0, void 0, void 0, function* () { const verifyMinimumGitVersion = () => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['--version'], { silent: false }); const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['--version'], { silent: process.env.ACTION_DEBUG === 'false' });
if (exitCode !== 0) { if (exitCode !== 0) {
throw new Error(stderr || 'An unexpected error occurred'); throw new Error(stderr || 'An unexpected error occurred');
} }
@@ -1334,7 +1329,7 @@ const getFilesFromSourceFile = ({ filePaths, excludedFiles = false }) => __await
const updateGitGlobalConfig = ({ name, value }) => __awaiter(void 0, void 0, void 0, function* () { const updateGitGlobalConfig = ({ name, value }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stderr } = yield exec.getExecOutput('git', ['config', '--global', name, value], { const { exitCode, stderr } = yield exec.getExecOutput('git', ['config', '--global', name, value], {
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
/* istanbul ignore if */ /* istanbul ignore if */
if (exitCode !== 0 || stderr) { if (exitCode !== 0 || stderr) {
@@ -1345,7 +1340,7 @@ exports.updateGitGlobalConfig = updateGitGlobalConfig;
const isRepoShallow = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { const isRepoShallow = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['rev-parse', '--is-shallow-repository'], { const { stdout } = yield exec.getExecOutput('git', ['rev-parse', '--is-shallow-repository'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
return stdout.trim() === 'true'; return stdout.trim() === 'true';
}); });
@@ -1354,7 +1349,7 @@ const submoduleExists = ({ cwd }) => __awaiter(void 0, void 0, void 0, function*
const { stdout, exitCode } = yield exec.getExecOutput('git', ['submodule', 'status'], { const { stdout, exitCode } = yield exec.getExecOutput('git', ['submodule', 'status'], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
return false; return false;
@@ -1366,7 +1361,7 @@ const gitFetch = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function*
const { exitCode } = yield exec.getExecOutput('git', ['fetch', '-q', ...args], { const { exitCode } = yield exec.getExecOutput('git', ['fetch', '-q', ...args], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
return exitCode; return exitCode;
}); });
@@ -1375,7 +1370,7 @@ const gitFetchSubmodules = ({ args, cwd }) => __awaiter(void 0, void 0, void 0,
const { exitCode, stderr } = yield exec.getExecOutput('git', ['submodule', 'foreach', 'git', 'fetch', '-q', ...args], { const { exitCode, stderr } = yield exec.getExecOutput('git', ['submodule', 'foreach', 'git', 'fetch', '-q', ...args], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
/* istanbul ignore if */ /* istanbul ignore if */
if (exitCode !== 0) { if (exitCode !== 0) {
@@ -1390,7 +1385,7 @@ const getSubmodulePath = ({ cwd }) => __awaiter(void 0, void 0, void 0, function
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], { const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
core.warning(stderr || "Couldn't get submodule names"); core.warning(stderr || "Couldn't get submodule names");
@@ -1406,7 +1401,7 @@ const gitSubmoduleDiffSHA = ({ cwd, parentSha1, parentSha2, submodulePath, diff
var _h, _j, _k, _l; var _h, _j, _k, _l;
const { stdout } = yield exec.getExecOutput('git', ['diff', parentSha1, parentSha2, '--', submodulePath], { const { stdout } = yield exec.getExecOutput('git', ['diff', parentSha1, parentSha2, '--', submodulePath], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
const subprojectCommitPreRegex = /^(?<preCommit>-)Subproject commit (?<commitHash>.+)$/m; const subprojectCommitPreRegex = /^(?<preCommit>-)Subproject commit (?<commitHash>.+)$/m;
const subprojectCommitCurRegex = /^(?<curCommit>\+)Subproject commit (?<commitHash>.+)$/m; const subprojectCommitCurRegex = /^(?<curCommit>\+)Subproject commit (?<commitHash>.+)$/m;
@@ -1430,7 +1425,7 @@ const gitRenamedFiles = ({ cwd, sha1, sha2, diff, oldNewSeparator, isSubmodule =
], { ], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
if (isSubmodule) { if (isSubmodule) {
@@ -1468,7 +1463,7 @@ const gitDiff = ({ cwd, sha1, sha2, diff, diffFilter, filePatterns = [], isSubmo
], { ], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
if (isSubmodule) { if (isSubmodule) {
@@ -1503,7 +1498,7 @@ exports.gitDiff = gitDiff;
const gitLog = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () { const gitLog = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['log', ...args], { const { stdout } = yield exec.getExecOutput('git', ['log', ...args], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
return stdout.trim(); return stdout.trim();
}); });
@@ -1511,7 +1506,7 @@ exports.gitLog = gitLog;
const getHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { const getHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD'], { const { stdout } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
return stdout.trim(); return stdout.trim();
}); });
@@ -1519,7 +1514,7 @@ exports.getHeadSha = getHeadSha;
const gitLsRemote = ({ cwd, args }) => __awaiter(void 0, void 0, void 0, function* () { const gitLsRemote = ({ cwd, args }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['ls-remote', 'origin', ...args], { const { stdout } = yield exec.getExecOutput('git', ['ls-remote', 'origin', ...args], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
const output = stdout.trim().split('\t'); const output = stdout.trim().split('\t');
if (output.length === 0) { if (output.length === 0) {
@@ -1528,19 +1523,19 @@ const gitLsRemote = ({ cwd, args }) => __awaiter(void 0, void 0, void 0, functio
return output[0]; return output[0];
}); });
exports.gitLsRemote = gitLsRemote; exports.gitLsRemote = gitLsRemote;
const getParentHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { const getParentSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD^'], { const { stdout } = yield exec.getExecOutput('git', ['rev-list', '-n', '1', 'HEAD^'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
return stdout.trim(); return stdout.trim();
}); });
exports.getParentHeadSha = getParentHeadSha; exports.getParentSha = getParentSha;
const verifyCommitSha = ({ sha, cwd, showAsErrorMessage = true }) => __awaiter(void 0, void 0, void 0, function* () { const verifyCommitSha = ({ sha, cwd, showAsErrorMessage = true }) => __awaiter(void 0, void 0, void 0, function* () {
const { exitCode, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--verify', `${sha}^{commit}`], { const { exitCode, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--verify', `${sha}^{commit}`], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
if (showAsErrorMessage) { if (showAsErrorMessage) {
@@ -1559,7 +1554,7 @@ exports.verifyCommitSha = verifyCommitSha;
const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () { const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-version:refname'], { const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-version:refname'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
const tags = stdout.trim().split('\n'); const tags = stdout.trim().split('\n');
if (tags.length < 2) { if (tags.length < 2) {
@@ -1569,7 +1564,7 @@ const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, functio
const previousTag = tags[1]; const previousTag = tags[1];
const { stdout: stdout2 } = yield exec.getExecOutput('git', ['rev-parse', previousTag], { const { stdout: stdout2 } = yield exec.getExecOutput('git', ['rev-parse', previousTag], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
const sha = stdout2.trim(); const sha = stdout2.trim();
return { tag: previousTag, sha }; return { tag: previousTag, sha };
@@ -1579,7 +1574,7 @@ const canDiffCommits = ({ cwd, sha1, sha2, diff }) => __awaiter(void 0, void 0,
const { exitCode, stderr } = yield exec.getExecOutput('git', ['diff', '--name-only', '--ignore-submodules=all', `${sha1}${diff}${sha2}`], { const { exitCode, stderr } = yield exec.getExecOutput('git', ['diff', '--name-only', '--ignore-submodules=all', `${sha1}${diff}${sha2}`], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}); });
if (exitCode !== 0) { if (exitCode !== 0) {
core.warning(stderr || `Unable find merge base between ${sha1} and ${sha2}`); core.warning(stderr || `Unable find merge base between ${sha1} and ${sha2}`);

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,7 @@ import {Inputs} from './inputs'
import { import {
canDiffCommits, canDiffCommits,
getHeadSha, getHeadSha,
getParentHeadSha, getParentSha,
getPreviousGitTag, getPreviousGitTag,
gitFetch, gitFetch,
gitFetchSubmodules, gitFetchSubmodules,
@@ -30,8 +30,7 @@ const getCurrentSHA = async ({
currentSha = await gitLog({ currentSha = await gitLog({
cwd: workingDirectory, cwd: workingDirectory,
args: [ args: [
'--format', '--format=%H',
'"%H"',
'-n', '-n',
'1', '1',
'--date', '--date',
@@ -75,7 +74,7 @@ export const getSHAForPushEvent = async (
gitExtraArgs: string[], gitExtraArgs: string[],
isTag: boolean isTag: boolean
): Promise<DiffResult> => { ): Promise<DiffResult> => {
let targetBranch = env.GITHUB_REFNAME let targetBranch = env.GITHUB_REF_NAME
const currentBranch = targetBranch const currentBranch = targetBranch
let initialCommit = false let initialCommit = false
@@ -154,19 +153,15 @@ export const getSHAForPushEvent = async (
if (inputs.since) { if (inputs.since) {
core.debug(`Getting base SHA for '${inputs.since}'...`) core.debug(`Getting base SHA for '${inputs.since}'...`)
try { try {
previousSha = await gitLog({ const allCommitsFrom = await gitLog({
cwd: workingDirectory, cwd: workingDirectory,
args: [ args: ['--format=%H', '--date', 'local', '--since', inputs.since]
'--format',
'"%H"',
'-n',
'1',
'--date',
'local',
'--since',
inputs.since
]
}) })
if (allCommitsFrom) {
const allCommitsFromArray = allCommitsFrom.split('\n')
previousSha = allCommitsFromArray[allCommitsFromArray.length - 1]
}
} catch (error) { } catch (error) {
core.error( core.error(
`Invalid since date: ${inputs.since}. ${(error as Error).message}` `Invalid since date: ${inputs.since}. ${(error as Error).message}`
@@ -179,33 +174,33 @@ export const getSHAForPushEvent = async (
previousSha = sha previousSha = sha
targetBranch = tag targetBranch = tag
} else { } else {
if (inputs.sinceLastRemoteCommit) {
core.debug('Getting previous SHA for last remote commit...') core.debug('Getting previous SHA for last remote commit...')
if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) { if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) {
previousSha = env.GITHUB_EVENT_BEFORE previousSha = env.GITHUB_EVENT_BEFORE
} else { } else {
previousSha = await getParentHeadSha({cwd: workingDirectory}) previousSha = await getParentSha({
} cwd: workingDirectory
} else { })
core.debug('Getting previous SHA for last commit...')
previousSha = await getParentHeadSha({cwd: workingDirectory})
} }
if ( if (
!previousSha || !previousSha ||
previousSha === '0000000000000000000000000000000000000000' previousSha === '0000000000000000000000000000000000000000'
) { ) {
previousSha = await getParentHeadSha({cwd: workingDirectory}) previousSha = await getParentSha({
cwd: workingDirectory
})
} }
if (previousSha === currentSha) { if (previousSha === currentSha) {
if (!(await getParentHeadSha({cwd: workingDirectory}))) { if (!(await getParentSha({cwd: workingDirectory}))) {
core.warning('Initial commit detected no previous commit found.') core.warning('Initial commit detected no previous commit found.')
initialCommit = true initialCommit = true
previousSha = currentSha previousSha = currentSha
} else { } else {
previousSha = await getParentHeadSha({cwd: workingDirectory}) previousSha = await getParentSha({
cwd: workingDirectory
})
} }
} else { } else {
if (!previousSha) { if (!previousSha) {

View File

@@ -5,7 +5,7 @@ export type Env = {
GITHUB_EVENT_PULL_REQUEST_HEAD_REF: string GITHUB_EVENT_PULL_REQUEST_HEAD_REF: string
GITHUB_EVENT_PULL_REQUEST_BASE_REF: string GITHUB_EVENT_PULL_REQUEST_BASE_REF: string
GITHUB_EVENT_BEFORE: string GITHUB_EVENT_BEFORE: string
GITHUB_REFNAME: string GITHUB_REF_NAME: string
GITHUB_REF: string GITHUB_REF: string
GITHUB_EVENT_BASE_REF: string GITHUB_EVENT_BASE_REF: string
GITHUB_EVENT_HEAD_REPO_FORK: string GITHUB_EVENT_HEAD_REPO_FORK: string
@@ -41,7 +41,6 @@ export const getEnv = async (): Promise<Env> => {
if (eventPath) { if (eventPath) {
eventJson = JSON.parse(await fs.readFile(eventPath, {encoding: 'utf8'})) eventJson = JSON.parse(await fs.readFile(eventPath, {encoding: 'utf8'}))
} }
core.debug(`Event: ${JSON.stringify(eventJson, null, 2)}`) core.debug(`Event: ${JSON.stringify(eventJson, null, 2)}`)
return { return {
@@ -53,7 +52,7 @@ export const getEnv = async (): Promise<Env> => {
GITHUB_EVENT_PULL_REQUEST_NUMBER: eventJson.pull_request?.number || '', GITHUB_EVENT_PULL_REQUEST_NUMBER: eventJson.pull_request?.number || '',
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: eventJson.pull_request?.base?.sha || '', GITHUB_EVENT_PULL_REQUEST_BASE_SHA: eventJson.pull_request?.base?.sha || '',
GITHUB_EVENT_FORCED: eventJson.forced || '', GITHUB_EVENT_FORCED: eventJson.forced || '',
GITHUB_REFNAME: process.env.GITHUB_REFNAME || '', GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || '',
GITHUB_REF: process.env.GITHUB_REF || '', GITHUB_REF: process.env.GITHUB_REF || '',
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || '' GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || ''
} }

View File

@@ -54,9 +54,11 @@ export async function run(): Promise<void> {
const hasSubmodule = await submoduleExists({cwd: workingDirectory}) const hasSubmodule = await submoduleExists({cwd: workingDirectory})
let gitExtraArgs = ['--no-tags', '--prune', '--recurse-submodules'] let gitExtraArgs = ['--no-tags', '--prune', '--recurse-submodules']
const isTag = env.GITHUB_REF?.startsWith('refs/tags/') const isTag = env.GITHUB_REF?.startsWith('refs/tags/')
const submodulePaths = await getSubmodulePath({ let submodulePaths: string[] = []
cwd: workingDirectory
}) if (hasSubmodule) {
submodulePaths = await getSubmodulePath({cwd: workingDirectory})
}
if (isTag) { if (isTag) {
gitExtraArgs = ['--prune', '--no-recurse-submodules'] gitExtraArgs = ['--prune', '--no-recurse-submodules']

View File

@@ -93,7 +93,7 @@ export const verifyMinimumGitVersion = async (): Promise<void> => {
const {exitCode, stdout, stderr} = await exec.getExecOutput( const {exitCode, stdout, stderr} = await exec.getExecOutput(
'git', 'git',
['--version'], ['--version'],
{silent: false} {silent: process.env.ACTION_DEBUG === 'false'}
) )
if (exitCode !== 0) { if (exitCode !== 0) {
@@ -177,7 +177,7 @@ export const updateGitGlobalConfig = async ({
['config', '--global', name, value], ['config', '--global', name, value],
{ {
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@@ -193,7 +193,7 @@ export const isRepoShallow = async ({cwd}: {cwd: string}): Promise<boolean> => {
['rev-parse', '--is-shallow-repository'], ['rev-parse', '--is-shallow-repository'],
{ {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@@ -211,7 +211,7 @@ export const submoduleExists = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@@ -232,7 +232,7 @@ export const gitFetch = async ({
const {exitCode} = await exec.getExecOutput('git', ['fetch', '-q', ...args], { const {exitCode} = await exec.getExecOutput('git', ['fetch', '-q', ...args], {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}) })
return exitCode return exitCode
@@ -251,7 +251,7 @@ export const gitFetchSubmodules = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@@ -276,7 +276,7 @@ export const getSubmodulePath = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@@ -309,7 +309,7 @@ export const gitSubmoduleDiffSHA = async ({
['diff', parentSha1, parentSha2, '--', submodulePath], ['diff', parentSha1, parentSha2, '--', submodulePath],
{ {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@@ -362,7 +362,7 @@ export const gitRenamedFiles = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@@ -434,7 +434,7 @@ export const gitDiff = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@@ -486,7 +486,7 @@ export const gitLog = async ({
}): Promise<string> => { }): Promise<string> => {
const {stdout} = await exec.getExecOutput('git', ['log', ...args], { const {stdout} = await exec.getExecOutput('git', ['log', ...args], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}) })
return stdout.trim() return stdout.trim()
@@ -495,7 +495,7 @@ export const gitLog = async ({
export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => { export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => {
const {stdout} = await exec.getExecOutput('git', ['rev-parse', 'HEAD'], { const {stdout} = await exec.getExecOutput('git', ['rev-parse', 'HEAD'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}) })
return stdout.trim() return stdout.trim()
@@ -513,7 +513,7 @@ export const gitLsRemote = async ({
['ls-remote', 'origin', ...args], ['ls-remote', 'origin', ...args],
{ {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
const output = stdout.trim().split('\t') const output = stdout.trim().split('\t')
@@ -525,15 +525,15 @@ export const gitLsRemote = async ({
return output[0] return output[0]
} }
export const getParentHeadSha = async ({ export const getParentSha = async ({cwd}: {cwd: string}): Promise<string> => {
cwd const {stdout} = await exec.getExecOutput(
}: { 'git',
cwd: string ['rev-list', '-n', '1', 'HEAD^'],
}): Promise<string> => { {
const {stdout} = await exec.getExecOutput('git', ['rev-parse', 'HEAD^'], {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
}) }
)
return stdout.trim() return stdout.trim()
} }
@@ -553,7 +553,7 @@ export const verifyCommitSha = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@@ -583,7 +583,7 @@ export const getPreviousGitTag = async ({
['tag', '--sort=-version:refname'], ['tag', '--sort=-version:refname'],
{ {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@@ -601,7 +601,7 @@ export const getPreviousGitTag = async ({
['rev-parse', previousTag], ['rev-parse', previousTag],
{ {
cwd, cwd,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )
@@ -627,7 +627,7 @@ export const canDiffCommits = async ({
{ {
cwd, cwd,
ignoreReturnCode: true, ignoreReturnCode: true,
silent: false silent: process.env.ACTION_DEBUG === 'false'
} }
) )