cherrypick.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { Task, TaskRunner } from './task';
  2. import GithubClient from '../utils/githubClient';
  3. interface CherryPickOptions {}
  4. const cherryPickRunner: TaskRunner<CherryPickOptions> = async () => {
  5. const githubClient = new GithubClient();
  6. const client = githubClient.client;
  7. const res = await client.get('/issues', {
  8. params: {
  9. state: 'closed',
  10. labels: 'cherry-pick needed',
  11. },
  12. });
  13. // sort by closed date ASC
  14. res.data.sort(function(a, b) {
  15. return new Date(a.closed_at).getTime() - new Date(b.closed_at).getTime();
  16. });
  17. let commands = '';
  18. console.log('--------------------------------------------------------------------');
  19. console.log('Printing PRs with cherry-pick-needed, in ASC merge date order');
  20. console.log('--------------------------------------------------------------------');
  21. for (const item of res.data) {
  22. if (!item.milestone) {
  23. console.log(item.number + ' missing milestone!');
  24. continue;
  25. }
  26. const issueDetails = await client.get(item.pull_request.url);
  27. console.log(`* ${item.title}, (#${item.number}), merge-sha: ${issueDetails.data.merge_commit_sha}`);
  28. commands += `git cherry-pick -x ${issueDetails.data.merge_commit_sha}\n`;
  29. }
  30. console.log('--------------------------------------------------------------------');
  31. console.log('Commands (in order of how they should be executed)');
  32. console.log('--------------------------------------------------------------------');
  33. console.log(commands);
  34. };
  35. export const cherryPickTask = new Task<CherryPickOptions>();
  36. cherryPickTask.setName('Cherry pick task');
  37. cherryPickTask.setRunner(cherryPickRunner);