build: Add GitHub scripts for rebasing PRs (#18359)

PR Close #18359
This commit is contained in:
Miško Hevery
2017-07-26 12:37:14 -07:00
committed by Miško Hevery
parent 2e714f9f2a
commit d1764fc3dd
10 changed files with 706 additions and 2 deletions

View File

@ -0,0 +1,28 @@
#!/usr/bin/env node
var msg = '';
if (require.main === module) {
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
const chunk = process.stdin.read();
if (chunk !== null) {
msg += chunk;
}
});
process.stdin.on('end', () => {
var argv = process.argv.slice(2);
console.log(rewriteMsg(msg, argv[0]));
});
}
function rewriteMsg(msg, prNo) {
var lines = msg.split(/\n/);
lines[0] += ' (#' + prNo +')';
lines.push('PR Close #' + prNo);
return lines.join('\n');
}
exports.rewriteMsg = rewriteMsg;

View File

@ -0,0 +1,54 @@
#!/usr/bin/env node
var json = '';
if (require.main === module) {
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
const chunk = process.stdin.read();
if (chunk !== null) {
json += chunk;
}
});
process.stdin.on('end', () => {
var obj = JSON.parse(json);
var argv = process.argv.slice(2);
extractPaths(obj, argv).forEach(function(line) {
console.log(line);
})
});
}
function extractPaths(obj, paths) {
var lines = [];
paths.forEach(function(exp) {
var objs = obj instanceof Array ? [].concat(obj) : [obj];
exp.split('.').forEach(function(name) {
for(var i = 0; i < objs.length; i++) {
var o = objs[i];
if (o instanceof Array) {
// Expand and do over
objs = objs.slice(0, i).concat(o).concat(objs.slice(i+1, objs.length));
i--;
} else {
name.split("=").forEach(function(name, index) {
if (index == 0) {
objs[i] = o = o[name];
} else if (name.charAt(0) == '^') {
if (o.indexOf(name.substr(1)) !== 0) {
objs.splice(i, 1);
i--;
}
}
});
}
}
});
lines.push(objs.join("|"));
});
return lines;
}
exports.extractPaths = extractPaths;

View File

@ -0,0 +1,39 @@
#!/usr/bin/env node
var assert = require("assert");
var extractPaths = require('./json_extract').extractPaths;
var SAMPLE_LABELS = [
{
"id": 149476251,
"url": "https://api.github.com/repos/angular/angular/labels/cla:%20yes",
"name": "cla: yes",
"color": "009800",
"default": false
},
{
"id": 533874619,
"url": "https://api.github.com/repos/angular/angular/labels/comp:%20aio",
"name": "comp: aio",
"color": "c7def8",
"default": false
},
{
"id": 133556520,
"url": "https://api.github.com/repos/angular/angular/labels/PR%20action:%20merge",
"name": "PR action: merge",
"color": "99ff66",
"default": false
},
{
"id": 655699838,
"url": "https://api.github.com/repos/angular/angular/labels/PR%20target:%20master%20&%20patch",
"name": "PR target: master & patch",
"color": "5319e7",
"default": false
}
];
assert.deepEqual(extractPaths({head: {label: 'value1'}}, ['head.label']), ['value1']);
assert.deepEqual(extractPaths(SAMPLE_LABELS, ['name']), ['cla: yes|comp: aio|PR action: merge|PR target: master & patch']);
assert.deepEqual(extractPaths(SAMPLE_LABELS, ['name=^PR target:']), ['PR target: master & patch']);

View File

@ -0,0 +1,30 @@
[
{
"id": 149476251,
"url": "https://api.github.com/repos/angular/angular/labels/cla:%20yes",
"name": "cla: yes",
"color": "009800",
"default": false
},
{
"id": 533874619,
"url": "https://api.github.com/repos/angular/angular/labels/comp:%20aio",
"name": "comp: aio",
"color": "c7def8",
"default": false
},
{
"id": 133556520,
"url": "https://api.github.com/repos/angular/angular/labels/PR%20action:%20merge",
"name": "PR action: merge",
"color": "99ff66",
"default": false
},
{
"id": 655699838,
"url": "https://api.github.com/repos/angular/angular/labels/PR%20target:%20master%20&%20patch",
"name": "PR target: master & patch",
"color": "5319e7",
"default": false
}
]

View File

@ -0,0 +1,314 @@
{
"url": "https://api.github.com/repos/angular/angular/pulls/18730",
"id": 136020267,
"html_url": "https://github.com/angular/angular/pull/18730",
"diff_url": "https://github.com/angular/angular/pull/18730.diff",
"patch_url": "https://github.com/angular/angular/pull/18730.patch",
"issue_url": "https://api.github.com/repos/angular/angular/issues/18730",
"number": 18730,
"state": "open",
"locked": false,
"title": "docs(aio): typo in metadata guide",
"user": {
"login": "cexbrayat",
"id": 411874,
"avatar_url": "https://avatars3.githubusercontent.com/u/411874?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/cexbrayat",
"html_url": "https://github.com/cexbrayat",
"followers_url": "https://api.github.com/users/cexbrayat/followers",
"following_url": "https://api.github.com/users/cexbrayat/following{/other_user}",
"gists_url": "https://api.github.com/users/cexbrayat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/cexbrayat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cexbrayat/subscriptions",
"organizations_url": "https://api.github.com/users/cexbrayat/orgs",
"repos_url": "https://api.github.com/users/cexbrayat/repos",
"events_url": "https://api.github.com/users/cexbrayat/events{/privacy}",
"received_events_url": "https://api.github.com/users/cexbrayat/received_events",
"type": "User",
"site_admin": false
},
"body": "## PR Type\r\n\r\nSimple typo fix in aio guide\r\n\r\n<!-- Please check the one that applies to this PR using \"x\". -->\r\n```\r\n[ ] Bugfix\r\n[ ] Feature\r\n[ ] Code style update (formatting, local variables)\r\n[ ] Refactoring (no functional changes, no api changes)\r\n[ ] Build related changes\r\n[ ] CI related changes\r\n[x] Documentation content changes\r\n[ ] angular.io application / infrastructure changes\r\n[ ] Other... Please describe:\r\n```",
"created_at": "2017-08-16T13:11:04Z",
"updated_at": "2017-08-17T13:59:21Z",
"closed_at": null,
"merged_at": null,
"merge_commit_sha": "35f8a4fdd7b37d41d8ed71c0f9978ed3e751da43",
"assignee": null,
"assignees": [
],
"requested_reviewers": [
],
"milestone": null,
"commits_url": "https://api.github.com/repos/angular/angular/pulls/18730/commits",
"review_comments_url": "https://api.github.com/repos/angular/angular/pulls/18730/comments",
"review_comment_url": "https://api.github.com/repos/angular/angular/pulls/comments{/number}",
"comments_url": "https://api.github.com/repos/angular/angular/issues/18730/comments",
"statuses_url": "https://api.github.com/repos/angular/angular/statuses/d59a5eec6cc60e301033300957f0c959b8056650",
"head": {
"label": "cexbrayat:docs/metadata-guide",
"ref": "docs/metadata-guide",
"sha": "d59a5eec6cc60e301033300957f0c959b8056650",
"user": {
"login": "cexbrayat",
"id": 411874,
"avatar_url": "https://avatars3.githubusercontent.com/u/411874?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/cexbrayat",
"html_url": "https://github.com/cexbrayat",
"followers_url": "https://api.github.com/users/cexbrayat/followers",
"following_url": "https://api.github.com/users/cexbrayat/following{/other_user}",
"gists_url": "https://api.github.com/users/cexbrayat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/cexbrayat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cexbrayat/subscriptions",
"organizations_url": "https://api.github.com/users/cexbrayat/orgs",
"repos_url": "https://api.github.com/users/cexbrayat/repos",
"events_url": "https://api.github.com/users/cexbrayat/events{/privacy}",
"received_events_url": "https://api.github.com/users/cexbrayat/received_events",
"type": "User",
"site_admin": false
},
"repo": {
"id": 25485740,
"name": "angular",
"full_name": "cexbrayat/angular",
"owner": {
"login": "cexbrayat",
"id": 411874,
"avatar_url": "https://avatars3.githubusercontent.com/u/411874?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/cexbrayat",
"html_url": "https://github.com/cexbrayat",
"followers_url": "https://api.github.com/users/cexbrayat/followers",
"following_url": "https://api.github.com/users/cexbrayat/following{/other_user}",
"gists_url": "https://api.github.com/users/cexbrayat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/cexbrayat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/cexbrayat/subscriptions",
"organizations_url": "https://api.github.com/users/cexbrayat/orgs",
"repos_url": "https://api.github.com/users/cexbrayat/repos",
"events_url": "https://api.github.com/users/cexbrayat/events{/privacy}",
"received_events_url": "https://api.github.com/users/cexbrayat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/cexbrayat/angular",
"description": null,
"fork": true,
"url": "https://api.github.com/repos/cexbrayat/angular",
"forks_url": "https://api.github.com/repos/cexbrayat/angular/forks",
"keys_url": "https://api.github.com/repos/cexbrayat/angular/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/cexbrayat/angular/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/cexbrayat/angular/teams",
"hooks_url": "https://api.github.com/repos/cexbrayat/angular/hooks",
"issue_events_url": "https://api.github.com/repos/cexbrayat/angular/issues/events{/number}",
"events_url": "https://api.github.com/repos/cexbrayat/angular/events",
"assignees_url": "https://api.github.com/repos/cexbrayat/angular/assignees{/user}",
"branches_url": "https://api.github.com/repos/cexbrayat/angular/branches{/branch}",
"tags_url": "https://api.github.com/repos/cexbrayat/angular/tags",
"blobs_url": "https://api.github.com/repos/cexbrayat/angular/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/cexbrayat/angular/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/cexbrayat/angular/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/cexbrayat/angular/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/cexbrayat/angular/statuses/{sha}",
"languages_url": "https://api.github.com/repos/cexbrayat/angular/languages",
"stargazers_url": "https://api.github.com/repos/cexbrayat/angular/stargazers",
"contributors_url": "https://api.github.com/repos/cexbrayat/angular/contributors",
"subscribers_url": "https://api.github.com/repos/cexbrayat/angular/subscribers",
"subscription_url": "https://api.github.com/repos/cexbrayat/angular/subscription",
"commits_url": "https://api.github.com/repos/cexbrayat/angular/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/cexbrayat/angular/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/cexbrayat/angular/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/cexbrayat/angular/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/cexbrayat/angular/contents/{+path}",
"compare_url": "https://api.github.com/repos/cexbrayat/angular/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/cexbrayat/angular/merges",
"archive_url": "https://api.github.com/repos/cexbrayat/angular/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/cexbrayat/angular/downloads",
"issues_url": "https://api.github.com/repos/cexbrayat/angular/issues{/number}",
"pulls_url": "https://api.github.com/repos/cexbrayat/angular/pulls{/number}",
"milestones_url": "https://api.github.com/repos/cexbrayat/angular/milestones{/number}",
"notifications_url": "https://api.github.com/repos/cexbrayat/angular/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/cexbrayat/angular/labels{/name}",
"releases_url": "https://api.github.com/repos/cexbrayat/angular/releases{/id}",
"deployments_url": "https://api.github.com/repos/cexbrayat/angular/deployments",
"created_at": "2014-10-20T20:42:42Z",
"updated_at": "2017-07-03T09:58:51Z",
"pushed_at": "2017-08-16T13:20:57Z",
"git_url": "git://github.com/cexbrayat/angular.git",
"ssh_url": "git@github.com:cexbrayat/angular.git",
"clone_url": "https://github.com/cexbrayat/angular.git",
"svn_url": "https://github.com/cexbrayat/angular",
"homepage": null,
"size": 62846,
"stargazers_count": 1,
"watchers_count": 1,
"language": "TypeScript",
"has_issues": false,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"open_issues_count": 0,
"forks": 0,
"open_issues": 0,
"watchers": 1,
"default_branch": "master"
}
},
"base": {
"label": "angular:master",
"ref": "master",
"sha": "32ff21c16bf1833d2da9f8e2ec8536f7a13f92de",
"user": {
"login": "angular",
"id": 139426,
"avatar_url": "https://avatars3.githubusercontent.com/u/139426?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/angular",
"html_url": "https://github.com/angular",
"followers_url": "https://api.github.com/users/angular/followers",
"following_url": "https://api.github.com/users/angular/following{/other_user}",
"gists_url": "https://api.github.com/users/angular/gists{/gist_id}",
"starred_url": "https://api.github.com/users/angular/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/angular/subscriptions",
"organizations_url": "https://api.github.com/users/angular/orgs",
"repos_url": "https://api.github.com/users/angular/repos",
"events_url": "https://api.github.com/users/angular/events{/privacy}",
"received_events_url": "https://api.github.com/users/angular/received_events",
"type": "Organization",
"site_admin": false
},
"repo": {
"id": 24195339,
"name": "angular",
"full_name": "angular/angular",
"owner": {
"login": "angular",
"id": 139426,
"avatar_url": "https://avatars3.githubusercontent.com/u/139426?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/angular",
"html_url": "https://github.com/angular",
"followers_url": "https://api.github.com/users/angular/followers",
"following_url": "https://api.github.com/users/angular/following{/other_user}",
"gists_url": "https://api.github.com/users/angular/gists{/gist_id}",
"starred_url": "https://api.github.com/users/angular/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/angular/subscriptions",
"organizations_url": "https://api.github.com/users/angular/orgs",
"repos_url": "https://api.github.com/users/angular/repos",
"events_url": "https://api.github.com/users/angular/events{/privacy}",
"received_events_url": "https://api.github.com/users/angular/received_events",
"type": "Organization",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/angular/angular",
"description": "One framework. Mobile & desktop.",
"fork": false,
"url": "https://api.github.com/repos/angular/angular",
"forks_url": "https://api.github.com/repos/angular/angular/forks",
"keys_url": "https://api.github.com/repos/angular/angular/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/angular/angular/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/angular/angular/teams",
"hooks_url": "https://api.github.com/repos/angular/angular/hooks",
"issue_events_url": "https://api.github.com/repos/angular/angular/issues/events{/number}",
"events_url": "https://api.github.com/repos/angular/angular/events",
"assignees_url": "https://api.github.com/repos/angular/angular/assignees{/user}",
"branches_url": "https://api.github.com/repos/angular/angular/branches{/branch}",
"tags_url": "https://api.github.com/repos/angular/angular/tags",
"blobs_url": "https://api.github.com/repos/angular/angular/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/angular/angular/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/angular/angular/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/angular/angular/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/angular/angular/statuses/{sha}",
"languages_url": "https://api.github.com/repos/angular/angular/languages",
"stargazers_url": "https://api.github.com/repos/angular/angular/stargazers",
"contributors_url": "https://api.github.com/repos/angular/angular/contributors",
"subscribers_url": "https://api.github.com/repos/angular/angular/subscribers",
"subscription_url": "https://api.github.com/repos/angular/angular/subscription",
"commits_url": "https://api.github.com/repos/angular/angular/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/angular/angular/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/angular/angular/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/angular/angular/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/angular/angular/contents/{+path}",
"compare_url": "https://api.github.com/repos/angular/angular/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/angular/angular/merges",
"archive_url": "https://api.github.com/repos/angular/angular/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/angular/angular/downloads",
"issues_url": "https://api.github.com/repos/angular/angular/issues{/number}",
"pulls_url": "https://api.github.com/repos/angular/angular/pulls{/number}",
"milestones_url": "https://api.github.com/repos/angular/angular/milestones{/number}",
"notifications_url": "https://api.github.com/repos/angular/angular/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/angular/angular/labels{/name}",
"releases_url": "https://api.github.com/repos/angular/angular/releases{/id}",
"deployments_url": "https://api.github.com/repos/angular/angular/deployments",
"created_at": "2014-09-18T16:12:01Z",
"updated_at": "2017-08-17T16:52:26Z",
"pushed_at": "2017-08-17T16:44:18Z",
"git_url": "git://github.com/angular/angular.git",
"ssh_url": "git@github.com:angular/angular.git",
"clone_url": "https://github.com/angular/angular.git",
"svn_url": "https://github.com/angular/angular",
"homepage": "https://angular.io",
"size": 64855,
"stargazers_count": 26993,
"watchers_count": 26993,
"language": "TypeScript",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"forks_count": 6796,
"mirror_url": null,
"open_issues_count": 1860,
"forks": 6796,
"open_issues": 1860,
"watchers": 26993,
"default_branch": "master"
}
},
"_links": {
"self": {
"href": "https://api.github.com/repos/angular/angular/pulls/18730"
},
"html": {
"href": "https://github.com/angular/angular/pull/18730"
},
"issue": {
"href": "https://api.github.com/repos/angular/angular/issues/18730"
},
"comments": {
"href": "https://api.github.com/repos/angular/angular/issues/18730/comments"
},
"review_comments": {
"href": "https://api.github.com/repos/angular/angular/pulls/18730/comments"
},
"review_comment": {
"href": "https://api.github.com/repos/angular/angular/pulls/comments{/number}"
},
"commits": {
"href": "https://api.github.com/repos/angular/angular/pulls/18730/commits"
},
"statuses": {
"href": "https://api.github.com/repos/angular/angular/statuses/d59a5eec6cc60e301033300957f0c959b8056650"
}
},
"merged": false,
"mergeable": true,
"rebaseable": true,
"mergeable_state": "clean",
"merged_by": null,
"comments": 0,
"review_comments": 2,
"maintainer_can_modify": true,
"commits": 1,
"additions": 1,
"deletions": 1,
"changed_files": 1
}