Skip to content

Commit 4c3e984

Browse files
author
Ben Wilhelm
committed
Undo all of prettier's reformatting to prepare upstream PR
1 parent 890911f commit 4c3e984

2 files changed

Lines changed: 57 additions & 62 deletions

File tree

action.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
name: "Query Tag"
2-
description: "Queries for a git tag using git describe"
3-
author: "Jim Schubert"
1+
name: 'Query Tag'
2+
description: 'Queries for a git tag using git describe'
3+
author: 'Jim Schubert'
44
inputs:
55
include:
6-
description: "Glob pattern of tags to include"
6+
description: 'Glob pattern of tags to include'
77
required: false
8-
default: "*"
8+
default: '*'
99
exclude:
10-
description: "Glob pattern of tags to exclude"
10+
description: 'Glob pattern of tags to exclude'
1111
required: false
1212
commit-ish:
13-
description: "Commit-ish object names to describe"
13+
description: 'Commit-ish object names to describe'
1414
required: false
15-
default: "HEAD~"
15+
default: 'HEAD~'
1616
skip-unshallow:
1717
description: 'Skip the unshallow operation: "true" or "false"'
1818
required: false
19-
default: "false"
19+
default: 'false'
2020
abbrev:
21-
description: "value to pass to the --abbrev flag. false to disable, default 0"
21+
description: 'value to pass the --abbrev flag. false to disable, default 0'
2222
required: false
2323
default: 0
24-
2524
outputs:
2625
tag:
27-
description: "The found tag"
26+
description: 'The found tag'
2827
runs:
29-
using: "node12"
30-
main: "main.js"
28+
using: 'node12'
29+
main: 'main.js'
3130
branding:
32-
icon: "hash"
33-
color: "green"
31+
icon: 'hash'
32+
color: 'green'

main.js

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,64 @@
1-
const { exec } = require("child_process");
1+
const { exec } = require('child_process');
22

33
// github actions pass inputs as environment variables prefixed with INPUT_ and uppercased
44
function getInput(key) {
5-
var variable = "INPUT_" + key;
6-
var result = process.env[variable.toUpperCase()];
7-
console.log(`Using input for ${key}: ${result}`);
8-
return result;
5+
var variable = 'INPUT_'+key;
6+
var result = process.env[variable.toUpperCase()];
7+
console.log(`Using input for ${key}: ${result}`);
8+
return result;
99
}
1010

1111
// rather than npm install @actions/core, output using the console logging syntax
1212
// see https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter
1313
function setOutput(key, value) {
14-
console.log(`::set-output name=${key}::${value}`);
14+
console.log(`::set-output name=${key}::${value}`)
1515
}
1616

1717
try {
18-
const include = getInput("include");
19-
const exclude = getInput("exclude");
20-
const commitIsh = getInput("commit-ish");
21-
const abbrev = getInput("abbrev");
22-
const skipUnshallow = getInput("skip-unshallow") === "true";
18+
const include = getInput('include');
19+
const exclude = getInput('exclude');
20+
const commitIsh = getInput('commit-ish');
21+
const skipUnshallow = getInput('skip-unshallow') === 'true';
22+
const abbrev = getInput("abbrev");
2323

24-
var includeOption = "";
25-
var excludeOption = "";
26-
var commitIshOption = "";
27-
var abbrevOption = "";
24+
var includeOption = '';
25+
var excludeOption = '';
26+
var commitIshOption = '';
27+
var abbrevOption = '';
2828

29-
if (typeof include === "string" && include.length > 0) {
30-
includeOption = `--match '${include}'`;
31-
}
29+
if (typeof include === 'string' && include.length > 0) {
30+
includeOption = `--match '${include}'`;
31+
}
3232

33-
if (typeof exclude === "string" && exclude.length > 0) {
34-
excludeOption = `--exclude '${exclude}'`;
35-
}
33+
if (typeof exclude === 'string' && exclude.length > 0) {
34+
excludeOption = `--exclude '${exclude}'`;
35+
}
3636

37-
if (typeof commitIsh === "string") {
38-
if (commitIsh === "" || commitIsh === "HEAD") {
39-
console.warn(
40-
'Passing empty string or HEAD to commit-ish will get the "current" tag rather than "previous". For previous tag, try "HEAD~".'
41-
);
37+
if (typeof commitIsh === 'string') {
38+
if (commitIsh === '' || commitIsh === 'HEAD') {
39+
console.warn('Passing empty string or HEAD to commit-ish will get the "current" tag rather than "previous". For previous tag, try "HEAD~".');
40+
}
41+
commitIshOption = `'${commitIsh}'`;
4242
}
43-
commitIshOption = `'${commitIsh}'`;
44-
}
4543

46-
if (abbrev !== "false") {
47-
abbrevOption = `--abbrev=${abbrev}`;
48-
}
44+
if (abbrev !== 'false') {
45+
abbrevOption = `--abbrev=${abbrev}`;
46+
}
4947

50-
var unshallowCmd = skipUnshallow ? "" : "git fetch --prune --unshallow &&";
48+
var unshallowCmd = skipUnshallow ? '' : 'git fetch --prune --unshallow &&'
5149

52-
// actions@checkout performs a shallow checkout. Need to unshallow for full tags access.
53-
var cmd = `${unshallowCmd} git describe --tags ${abbrevOption} ${includeOption} ${excludeOption} ${commitIshOption}`
54-
.replace(/[ ]+/, " ")
55-
.trim();
56-
console.log(`Executing: ${cmd}`);
50+
// actions@checkout performs a shallow checkout. Need to unshallow for full tags access.
51+
var cmd = `${unshallowCmd} git describe --tags ${abbrevOption} ${includeOption} ${excludeOption} ${commitIshOption}`.replace(/[ ]+/, ' ').trim();
52+
console.log(`Executing: ${cmd}`);
5753

58-
exec(cmd, (err, tag, stderr) => {
59-
if (err) {
60-
console.error(`Unable to find an earlier tag.\n${stderr}`);
61-
return process.exit(1);
62-
}
63-
console.log(`Outputting tag: ${tag.trim()}`);
64-
return setOutput("tag", tag.trim());
65-
});
54+
exec(cmd, (err, tag, stderr) => {
55+
if (err) {
56+
console.error(`Unable to find an earlier tag.\n${stderr}`);
57+
return process.exit(1);
58+
}
59+
console.log(`Outputting tag: ${tag.trim()}`)
60+
return setOutput('tag', tag.trim());
61+
});
6662
} catch (error) {
67-
core.setFailed(error.message);
63+
core.setFailed(error.message);
6864
}

0 commit comments

Comments
 (0)