Skip to content

Commit

Permalink
Merge pull request #4 from mitchell-codecov/frouioui-main
Browse files Browse the repository at this point in the history
Merge dorny#133
  • Loading branch information
mitchell-codecov committed Jun 15, 2022
2 parents 370fff3 + 0896569 commit 5652caa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion dist/index.js
Expand Up @@ -570,6 +570,7 @@ function getConfigFileContent(configPath) {
return fs.readFileSync(configPath, { encoding: 'utf8' });
}
async function getChangedFiles(token, base, ref, initialFetchDepth) {
var _a, _b;
// if base is 'HEAD' only local uncommitted changes will be detected
// This is the simplest case as we don't need to fetch more commits or evaluate current/before refs
if (base === git.HEAD) {
Expand Down Expand Up @@ -597,7 +598,10 @@ async function getChangedFiles(token, base, ref, initialFetchDepth) {
throw new Error(`'token' input parameter is required if action is triggered by 'pull_request_target' event`);
}
core.info('Github token is not available - changes will be detected from PRs merge commit');
return await git.getChangesInLastCommit();
const baseSha = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.base.sha;
const defaultBranch = (_b = github.context.payload.repository) === null || _b === void 0 ? void 0 : _b.default_branch;
const currentRef = await git.getCurrentRef();
return await git.getChanges(base || baseSha || defaultBranch, currentRef);
}
else {
return getChangedFilesFromGit(base, ref, initialFetchDepth);
Expand Down
6 changes: 5 additions & 1 deletion src/main.ts
Expand Up @@ -8,6 +8,7 @@ import {File, ChangeStatus} from './file'
import * as git from './git'
import {backslashEscape, shellEscape} from './list-format/shell-escape'
import {csvEscape} from './list-format/csv-escape'
import {getChanges} from './git'

type ExportFormat = 'none' | 'csv' | 'json' | 'shell' | 'escape'

Expand Down Expand Up @@ -86,7 +87,10 @@ async function getChangedFiles(token: string, base: string, ref: string, initial
throw new Error(`'token' input parameter is required if action is triggered by 'pull_request_target' event`)
}
core.info('Github token is not available - changes will be detected from PRs merge commit')
return await git.getChangesInLastCommit()
const baseSha = github.context.payload.pull_request?.base.sha
const defaultBranch = github.context.payload.repository?.default_branch
const currentRef = await git.getCurrentRef()
return await git.getChanges(base || baseSha || defaultBranch, currentRef)
} else {
return getChangedFilesFromGit(base, ref, initialFetchDepth)
}
Expand Down

0 comments on commit 5652caa

Please sign in to comment.