fix: error using current path to determine the .git dir location (#1299)

Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: tj-actions[bot] <109116665+tj-actions-bot@users.noreply.github.com>
This commit is contained in:
Tonye Jack 2023-06-24 09:27:16 -06:00 committed by GitHub
parent d6d7cb291e
commit e5efec47f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 6 deletions

17
dist/index.js generated vendored
View File

@ -1641,7 +1641,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.hasLocalGitDirectory = exports.recoverDeletedFiles = exports.setOutput = exports.getYamlFilePatterns = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.getRemoteBranchHeadSha = exports.getHeadSha = exports.gitLog = exports.getFilteredChangedFiles = exports.getAllChangedFiles = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0; exports.hasLocalGitDirectory = exports.recoverDeletedFiles = exports.setOutput = exports.getYamlFilePatterns = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.getRemoteBranchHeadSha = exports.isInsideWorkTree = exports.getHeadSha = exports.gitLog = exports.getFilteredChangedFiles = exports.getAllChangedFiles = 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));
@ -2030,6 +2030,15 @@ const getHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
return stdout.trim(); return stdout.trim();
}); });
exports.getHeadSha = getHeadSha; exports.getHeadSha = getHeadSha;
const isInsideWorkTree = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['rev-parse', '--is-inside-work-tree'], {
cwd,
ignoreReturnCode: true,
silent: !core.isDebug()
});
return stdout.trim() === 'true';
});
exports.isInsideWorkTree = isInsideWorkTree;
const getRemoteBranchHeadSha = ({ cwd, branch }) => __awaiter(void 0, void 0, void 0, function* () { const getRemoteBranchHeadSha = ({ cwd, branch }) => __awaiter(void 0, void 0, void 0, function* () {
const { stdout } = yield exec.getExecOutput('git', ['rev-parse', `origin/${branch}`], { const { stdout } = yield exec.getExecOutput('git', ['rev-parse', `origin/${branch}`], {
cwd, cwd,
@ -2345,8 +2354,10 @@ const recoverDeletedFiles = ({ inputs, workingDirectory, deletedFiles, sha }) =>
}); });
exports.recoverDeletedFiles = recoverDeletedFiles; exports.recoverDeletedFiles = recoverDeletedFiles;
const hasLocalGitDirectory = ({ workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () { const hasLocalGitDirectory = ({ workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () {
const gitDirectory = path.join(workingDirectory, '.git'); const insideWorkTree = yield (0, exports.isInsideWorkTree)({
return yield exists(gitDirectory); cwd: workingDirectory
});
return insideWorkTree;
}); });
exports.hasLocalGitDirectory = hasLocalGitDirectory; exports.hasLocalGitDirectory = hasLocalGitDirectory;

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -552,6 +552,24 @@ export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => {
return stdout.trim() return stdout.trim()
} }
export const isInsideWorkTree = async ({
cwd
}: {
cwd: string
}): Promise<boolean> => {
const {stdout} = await exec.getExecOutput(
'git',
['rev-parse', '--is-inside-work-tree'],
{
cwd,
ignoreReturnCode: true,
silent: !core.isDebug()
}
)
return stdout.trim() === 'true'
}
export const getRemoteBranchHeadSha = async ({ export const getRemoteBranchHeadSha = async ({
cwd, cwd,
branch branch
@ -1103,6 +1121,9 @@ export const hasLocalGitDirectory = async ({
}: { }: {
workingDirectory: string workingDirectory: string
}): Promise<boolean> => { }): Promise<boolean> => {
const gitDirectory = path.join(workingDirectory, '.git') const insideWorkTree = await isInsideWorkTree({
return await exists(gitDirectory) cwd: workingDirectory
})
return insideWorkTree
} }