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:
parent
d6d7cb291e
commit
e5efec47f6
17
dist/index.js
generated
vendored
17
dist/index.js
generated
vendored
@ -1641,7 +1641,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
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*/
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const exec = __importStar(__nccwpck_require__(1514));
|
||||
@ -2030,6 +2030,15 @@ const getHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
return stdout.trim();
|
||||
});
|
||||
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 { stdout } = yield exec.getExecOutput('git', ['rev-parse', `origin/${branch}`], {
|
||||
cwd,
|
||||
@ -2345,8 +2354,10 @@ const recoverDeletedFiles = ({ inputs, workingDirectory, deletedFiles, sha }) =>
|
||||
});
|
||||
exports.recoverDeletedFiles = recoverDeletedFiles;
|
||||
const hasLocalGitDirectory = ({ workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const gitDirectory = path.join(workingDirectory, '.git');
|
||||
return yield exists(gitDirectory);
|
||||
const insideWorkTree = yield (0, exports.isInsideWorkTree)({
|
||||
cwd: workingDirectory
|
||||
});
|
||||
return insideWorkTree;
|
||||
});
|
||||
exports.hasLocalGitDirectory = hasLocalGitDirectory;
|
||||
|
||||
|
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
25
src/utils.ts
25
src/utils.ts
@ -552,6 +552,24 @@ export const getHeadSha = async ({cwd}: {cwd: string}): Promise<string> => {
|
||||
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 ({
|
||||
cwd,
|
||||
branch
|
||||
@ -1103,6 +1121,9 @@ export const hasLocalGitDirectory = async ({
|
||||
}: {
|
||||
workingDirectory: string
|
||||
}): Promise<boolean> => {
|
||||
const gitDirectory = path.join(workingDirectory, '.git')
|
||||
return await exists(gitDirectory)
|
||||
const insideWorkTree = await isInsideWorkTree({
|
||||
cwd: workingDirectory
|
||||
})
|
||||
|
||||
return insideWorkTree
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user