diff --git a/scripts/cherryPick.js b/scripts/cherryPick.js index 3bd70a7e1db..51683d495cc 100644 --- a/scripts/cherryPick.js +++ b/scripts/cherryPick.js @@ -22,6 +22,7 @@ let arrTitle = []; let arrURL = []; let arrSHA = []; let arrBranch = []; +let arrUser = []; const repo = "vaadin/vaadin-flow-components"; const token = process.env['GITHUB_TOKEN']; @@ -73,12 +74,13 @@ function filterCommits(commits){ commit.labels.forEach(label => { let branch = /target\/(.*)/.exec(label.name); if (branch){ - console.log(commit.number, commit.url, commit.merge_commit_sha, branch[1]); + console.log(commit.number, commit.user.login, commit.url, commit.merge_commit_sha, branch[1]); arrPR.push(commit.number); arrSHA.push(commit.merge_commit_sha); arrURL.push(commit.url); arrBranch.push(branch[1]); arrTitle.push(`${commit.title} (#${commit.number}) (CP: ${branch[1]})`); + arrUser.push(`@${commit.user.login}`); } }) } @@ -108,6 +110,7 @@ async function cherryPickCommits(){ await exec(`git checkout master`); await exec(`git branch -D ${branchName}`); await labelCommit(arrURL[i], `need to pick manually`); + await postComment(arrURL[i], arrUser[i], arrBranch[i]); console.error(`Cannot Pick the Commit:${arrSHA[i]}, error :${err}`); continue; } @@ -132,6 +135,18 @@ async function labelCommit(url, label){ await axios.post(issueURL, {"labels":[label]}, options); } +async function postComment(url, userName, branch){ + let issueURL = url.replace("pulls", "issues") + "/comments"; + const options = { + headers:{ + 'User-Agent': 'Vaadin Cherry Pick', + 'Authorization': `token ${token}`, + } + }; + + await axios.post(issueURL, {"body":`Hi ${userName} , this commit cannot be picked to ${branch} by this bot, can you take a look and pick it manually?`}, options); +} + async function createPR(title, head, base){ const payload = {title, head, base};