diff --git a/dist/index.js b/dist/index.js index 4d82840..5eec7fb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -363,8 +363,8 @@ exports.listAllFilesAsAdded = listAllFilesAsAdded; async function getCurrentRef() { core.startGroup(`Get current git ref`); try { - const branch = (await (0, exec_1.getExecOutput)('git', ['branch', '--show-current'])).stdout.trim(); - if (branch) { + const branch = (await (0, exec_1.getExecOutput)('git', ['rev-parse', '--abbrev-ref', 'HEAD'])).stdout.trim(); + if (branch && branch !== 'HEAD') { return branch; } const describe = await (0, exec_1.getExecOutput)('git', ['describe', '--tags', '--exact-match'], { ignoreReturnCode: true }); diff --git a/src/git.ts b/src/git.ts index a413236..9615f8b 100644 --- a/src/git.ts +++ b/src/git.ts @@ -166,8 +166,8 @@ export async function listAllFilesAsAdded(): Promise { export async function getCurrentRef(): Promise { core.startGroup(`Get current git ref`) try { - const branch = (await getExecOutput('git', ['branch', '--show-current'])).stdout.trim() - if (branch) { + const branch = (await getExecOutput('git', ['rev-parse', '--abbrev-ref', 'HEAD'])).stdout.trim() + if (branch && branch !== 'HEAD') { return branch }