forked from lo1tuma/pr-log
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use up-to-date github PR title instead of merge-commit title
- Loading branch information
Showing
3 changed files
with
28 additions
and
38 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import rest from 'restling'; | ||
|
||
const accessToken = process.env.GH_TOKEN; // eslint-disable-line | ||
const header = accessToken ? { accessToken } : {}; | ||
|
||
function getLabel(labels, validLabels) { | ||
const validLabelNames = Object.keys(validLabels); | ||
const listOfLabels = validLabelNames.join(', '); | ||
const filteredLabels = labels.filter((label) => { | ||
return validLabelNames.indexOf(label.name) !== -1; | ||
}); | ||
return (filteredLabels.length === 0) ? 'other' : filteredLabels[0].name; | ||
} | ||
|
||
function getPullRequestLabel(githubRepo, validLabels, pullRequestId) { | ||
const url = `https://api.github.com/repos/${githubRepo}/issues/${pullRequestId}`; | ||
return rest.get(url, header) | ||
.get('data') | ||
.then((pr) => { | ||
const { title, labels } = pr; | ||
const label = getLabel(labels, validLabels); | ||
return { id: pullRequestId, title, label }; | ||
}); | ||
} | ||
|
||
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 was deleted.
Oops, something went wrong.