-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
56 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
}, | ||
|
||
"parserOptions": { | ||
"ecmaVersion": "2017", | ||
"ecmaFeatures": { | ||
"globalReturn": false | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
import rest from 'restling'; | ||
|
||
function getPullRequestLabel(githubRepo, validLabels, pullRequestId) { | ||
async function getPullRequestLabel(githubRepo, validLabels, pullRequestId) { | ||
const validLabelNames = Object.keys(validLabels); | ||
const url = `https://api.github.com/repos/${githubRepo}/issues/${pullRequestId}/labels`; | ||
|
||
return rest.get(url) | ||
.get('data') | ||
.then((labels) => { | ||
const listOfLabels = validLabelNames.join(', '); | ||
const filteredLabels = labels.filter((label) => { | ||
return validLabelNames.indexOf(label.name) !== -1; | ||
}); | ||
const { data: labels } = await rest.get(url); | ||
|
||
if (filteredLabels.length > 1) { | ||
throw new Error(`Pull Request #${pullRequestId} has multiple labels of ${listOfLabels}`); | ||
} else if (filteredLabels.length === 0) { | ||
throw new Error(`Pull Request #${pullRequestId} has no label of ${listOfLabels}`); | ||
} | ||
const listOfLabels = validLabelNames.join(', '); | ||
const filteredLabels = labels.filter((label) => { | ||
return validLabelNames.indexOf(label.name) !== -1; | ||
}); | ||
|
||
return filteredLabels[0].name; | ||
}); | ||
if (filteredLabels.length > 1) { | ||
throw new Error(`Pull Request #${pullRequestId} has multiple labels of ${listOfLabels}`); | ||
} else if (filteredLabels.length === 0) { | ||
throw new Error(`Pull Request #${pullRequestId} has no label of ${listOfLabels}`); | ||
} | ||
|
||
return filteredLabels[0].name; | ||
} | ||
|
||
export default getPullRequestLabel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters