Skip to content

Commit f5c0ac9

Browse files
authored
Update action.js
1 parent 6d3bec4 commit f5c0ac9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

action.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ const getHead = name => data => name === "pull_request" ? data.pull_request.head
1010
const normalise = path => path.split("/").filter(item => item !== "" && item !== ".").join("/");
1111
const toBoolean = value => value.toLowerCase() == "true";
1212

13-
14-
const setFromPath = octokit => owner => async repo => {
13+
const setFromPath = owner => repo => async octokit => {
1514
try {
1615
const input_path = core.getInput("path");
1716
if (input_path) return normalise(input_path);
@@ -37,10 +36,10 @@ const setFromPath = octokit => owner => async repo => {
3736

3837
const contentsUrlDoesMatch = file => target => {
3938
const contents_url = decodeURIComponent(file.contents_url);
40-
const contents_path = contents_url.substring(contents_url.indexOf("contents/"), contents_url.indexOf("?ref="));
41-
const doesMatch = minimatch(contents_path, `contents/${target}`);
42-
console.log(contents_path, `contents/${target}`, doesMatch);
43-
return doesMatch;
39+
const start = contents_url.indexOf("contents/");
40+
const end = contents_url.indexOf("?ref=");
41+
const contents_path = contents_url.substring(start, end);
42+
return minimatch(contents_path, `contents/${target}`);
4443
};
4544

4645
(async function(){
@@ -61,10 +60,9 @@ const contentsUrlDoesMatch = file => target => {
6160
if (response.status !== 200) throw `The API request for this ${github.context.eventName} event returned ${response.status}, expected 200.`;
6261
if (response.data.status !== "ahead") throw `The head commit for this ${github.context.eventName} event is not ahead of the base commit.`;
6362

64-
const target = await setFromPath(octokit)(owner)(repo);
6563
const files = response.data.files;
64+
const target = await setFromPath(owner)(repo)(octokit);
6665
const file = files.find(file => contentsUrlDoesMatch(file)(target));
67-
// decodeURIComponent(file.contents_url).indexOf(`contents/${target}`) !== -1);
6866

6967
core.setOutput("name", file ? file.filename : target);
7068
core.setOutput("added", file ? file.status === "added" : false);

0 commit comments

Comments
 (0)