Skip to content

Commit 3ed7ce2

Browse files
authored
Merge pull request #2 from w69b/master
Adds `abbrev` option to override --abbrev=0
2 parents 28ed6df + 4c3e984 commit 3ed7ce2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ inputs:
1717
description: 'Skip the unshallow operation: "true" or "false"'
1818
required: false
1919
default: 'false'
20+
abbrev:
21+
description: 'value to pass the --abbrev flag. false to disable, default 0'
22+
required: false
23+
default: 0
2024
outputs:
2125
tag:
2226
description: 'The found tag'
2327
runs:
2428
using: 'node12'
2529
main: 'main.js'
2630
branding:
27-
icon: 'hash'
31+
icon: 'hash'
2832
color: 'green'

main.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ try {
1919
const exclude = getInput('exclude');
2020
const commitIsh = getInput('commit-ish');
2121
const skipUnshallow = getInput('skip-unshallow') === 'true';
22+
const abbrev = getInput("abbrev");
2223

2324
var includeOption = '';
2425
var excludeOption = '';
2526
var commitIshOption = '';
27+
var abbrevOption = '';
2628

2729
if (typeof include === 'string' && include.length > 0) {
2830
includeOption = `--match '${include}'`;
@@ -39,10 +41,14 @@ try {
3941
commitIshOption = `'${commitIsh}'`;
4042
}
4143

44+
if (abbrev !== 'false') {
45+
abbrevOption = `--abbrev=${abbrev}`;
46+
}
47+
4248
var unshallowCmd = skipUnshallow ? '' : 'git fetch --prune --unshallow &&'
4349

4450
// actions@checkout performs a shallow checkout. Need to unshallow for full tags access.
45-
var cmd = `${unshallowCmd} git describe --tags --abbrev=0 ${includeOption} ${excludeOption} ${commitIshOption}`.replace(/[ ]+/, ' ').trim();
51+
var cmd = `${unshallowCmd} git describe --tags ${abbrevOption} ${includeOption} ${excludeOption} ${commitIshOption}`.replace(/[ ]+/, ' ').trim();
4652
console.log(`Executing: ${cmd}`);
4753

4854
exec(cmd, (err, tag, stderr) => {

0 commit comments

Comments
 (0)