Skip to content

Commit

Permalink
Use up-to-date github PR title instead of merge-commit title
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman authored and ndelangen committed Jul 28, 2017
1 parent 1811103 commit 86cdce0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 38 deletions.
26 changes: 26 additions & 0 deletions lib/getGithubPullRequest.js
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;
11 changes: 2 additions & 9 deletions lib/getMergedPullRequests.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import git from 'git-promise';
import Promise from 'bluebird';
import semver from 'semver';
import getPullRequestLabel from './getPullRequestLabel';
import getGithubPullRequest from './getGithubPullRequest';

function getLatestVersionTag() {
return git('tag --list')
Expand All @@ -28,14 +28,7 @@ function getPullRequests(fromTag) {

function extendWithLabel(githubRepo, validLabels, pullRequests) {
const promises = pullRequests.map((pullRequest) => {
return getPullRequestLabel(githubRepo, validLabels, pullRequest.id)
.then((label) => {
return {
id: pullRequest.id,
title: pullRequest.title,
label
};
});
return getGithubPullRequest(githubRepo, validLabels, pullRequest.id);
});

return Promise.all(promises);
Expand Down
29 changes: 0 additions & 29 deletions lib/getPullRequestLabel.js

This file was deleted.

0 comments on commit 86cdce0

Please sign in to comment.