Skip to content
Snippets Groups Projects
Commit 24d23dfc authored by Rhys Arkins's avatar Rhys Arkins
Browse files

Add description to Pull Request

Closes #15
parent bcc31712
No related branches found
No related tags found
No related merge requests found
...@@ -86,17 +86,18 @@ function updateDependency(depType, depName, currentVersion, nextVersion) { ...@@ -86,17 +86,18 @@ function updateDependency(depType, depName, currentVersion, nextVersion) {
if (res.body.length > 0) { if (res.body.length > 0) {
console.log(`Dependency ${depName} upgrade to ${nextVersionMajor}.x PR already existed, so skipping`); console.log(`Dependency ${depName} upgrade to ${nextVersionMajor}.x PR already existed, so skipping`);
} else { } else {
writeUpdates(depType, depName, branchName, prName, nextVersion); writeUpdates(depType, depName, branchName, prName, currentVersion, nextVersion);
} }
}); });
} else { } else {
prName = `Upgrade dependency ${depName} to version ${nextVersion}`; prName = `Upgrade dependency ${depName} to version ${nextVersion}`;
writeUpdates(depType, depName, branchName, prName, nextVersion); writeUpdates(depType, depName, branchName, prName, currentVersion, nextVersion);
} }
} }
function writeUpdates(depType, depName, branchName, prName, nextVersion) { function writeUpdates(depType, depName, branchName, prName, currentVersion, nextVersion) {
const commitMessage = `Upgrade dependency ${depName} to version ${nextVersion}`; const commitMessage = `Upgrade dependency ${depName} to version ${nextVersion}`;
const prBody = `This Pull Request updates dependency ${depName} from version ${currentVersion} to ${nextVersion}.`;
// Try to create branch // Try to create branch
const body = { const body = {
ref: `refs/heads/${branchName}`, ref: `refs/heads/${branchName}`,
...@@ -130,7 +131,7 @@ function writeUpdates(depType, depName, branchName, prName, nextVersion) { ...@@ -130,7 +131,7 @@ function writeUpdates(depType, depName, branchName, prName, nextVersion) {
content: new Buffer(branchPackageString).toString('base64') content: new Buffer(branchPackageString).toString('base64')
} }
}).then(res => { }).then(res => {
return createOrUpdatePullRequest(branchName, prName); return createOrUpdatePullRequest(branchName, prName, prBody);
}); });
} }
}); });
...@@ -140,14 +141,14 @@ function writeUpdates(depType, depName, branchName, prName, nextVersion) { ...@@ -140,14 +141,14 @@ function writeUpdates(depType, depName, branchName, prName, nextVersion) {
}); });
} }
function createOrUpdatePullRequest(branchName, title) { function createOrUpdatePullRequest(branchName, title, body) {
return ghGot.post(`repos/${repoName}/pulls`, { return ghGot.post(`repos/${repoName}/pulls`, {
token: token, token: token,
body: { body: {
title: title, title: title,
head: branchName, head: branchName,
base: 'master', base: 'master',
body: '' body: body,
} }
}).then(res => { }).then(res => {
console.log('Created Pull Request: ' + title); console.log('Created Pull Request: ' + title);
...@@ -167,7 +168,8 @@ function createOrUpdatePullRequest(branchName, title) { ...@@ -167,7 +168,8 @@ function createOrUpdatePullRequest(branchName, title) {
return ghGot.patch(`repos/${repoName}/pulls/${existingPrNo}`, { return ghGot.patch(`repos/${repoName}/pulls/${existingPrNo}`, {
token: token, token: token,
body: { body: {
title: title title: title,
body: body,
} }
}).then(res => { }).then(res => {
console.log('Updated Pull Request: ' + title); console.log('Updated Pull Request: ' + title);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment