Skip to content

Commit f3ceefd

Browse files
fix: use rev-parse instead of branch --show-current for older git compat (#303)
1 parent 61f87a1 commit f3ceefd

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ exports.listAllFilesAsAdded = listAllFilesAsAdded;
363363
async function getCurrentRef() {
364364
core.startGroup(`Get current git ref`);
365365
try {
366-
const branch = (await (0, exec_1.getExecOutput)('git', ['branch', '--show-current'])).stdout.trim();
367-
if (branch) {
366+
const branch = (await (0, exec_1.getExecOutput)('git', ['rev-parse', '--abbrev-ref', 'HEAD'])).stdout.trim();
367+
if (branch && branch !== 'HEAD') {
368368
return branch;
369369
}
370370
const describe = await (0, exec_1.getExecOutput)('git', ['describe', '--tags', '--exact-match'], { ignoreReturnCode: true });

src/git.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ export async function listAllFilesAsAdded(): Promise<File[]> {
166166
export async function getCurrentRef(): Promise<string> {
167167
core.startGroup(`Get current git ref`)
168168
try {
169-
const branch = (await getExecOutput('git', ['branch', '--show-current'])).stdout.trim()
170-
if (branch) {
169+
const branch = (await getExecOutput('git', ['rev-parse', '--abbrev-ref', 'HEAD'])).stdout.trim()
170+
if (branch && branch !== 'HEAD') {
171171
return branch
172172
}
173173

0 commit comments

Comments
 (0)