Skip to content

Commit

Permalink
fix: associated pull requests should match merge commit sha (#817)
Browse files Browse the repository at this point in the history
  • Loading branch information
chingor13 committed Mar 9, 2021
1 parent 89e5bed commit c144f8b
Show file tree
Hide file tree
Showing 11 changed files with 355 additions and 64 deletions.
16 changes: 13 additions & 3 deletions src/github.ts
Expand Up @@ -149,6 +149,9 @@ interface GraphQLCommit {
name: string;
}[];
};
mergeCommit?: {
oid: string;
};
}[];
};
}
Expand Down Expand Up @@ -658,7 +661,7 @@ export class GitHub {
... on Commit {
history(first: $num, after: $cursor) {
nodes {
associatedPullRequests(first: 1) {
associatedPullRequests(first: 10) {
nodes {
number
title
Expand All @@ -670,6 +673,9 @@ export class GitHub {
}
}
body
mergeCommit {
oid
}
}
}
sha: oid
Expand Down Expand Up @@ -701,8 +707,12 @@ export class GitHub {
message: graphCommit.message,
files: [] as string[],
};
if (graphCommit.associatedPullRequests.nodes.length > 0) {
const pullRequest = graphCommit.associatedPullRequests.nodes[0];
const pullRequest = graphCommit.associatedPullRequests.nodes.find(
pr => {
return pr.mergeCommit && pr.mergeCommit.oid === graphCommit.sha;
}
);
if (pullRequest) {
return {
commit,
pullRequest: {
Expand Down
45 changes: 36 additions & 9 deletions test/fixtures/commits-since-page-1.json
Expand Up @@ -15,7 +15,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "e6daec403626c9987c7af0d97b34f324cd84320a"
}
}
]
},
Expand All @@ -33,7 +36,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "b29149f890e6f76ee31ed128585744d4c598924c"
}
}
]
},
Expand All @@ -51,7 +57,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "27d7d7232e2e312d1380e906984f0823f5decf61"
}
}
]
},
Expand All @@ -69,7 +78,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "2b4e0b3be2e231cd87cc44c411bd8f84b4587ab5"
}
}
]
},
Expand All @@ -87,7 +99,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "a257514a541d483425118d973674b1ce006a5489"
}
}
]
},
Expand All @@ -105,7 +120,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "b6a8ab1a50106cfb03f22c2cdaf7abfdcccce088"
}
}
]
},
Expand All @@ -123,7 +141,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "520b6f42551c86002197d033564a76a3f99b0019"
}
}
]
},
Expand All @@ -145,7 +166,10 @@
}
]
},
"body": ":robot: I have created a release \\*beep\\* \\*boop\\* \n---\n### Updating meta-information for bleeding-edge SNAPSHOT release.\n---\n\n\nThis PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please)."
"body": ":robot: I have created a release \\*beep\\* \\*boop\\* \n---\n### Updating meta-information for bleeding-edge SNAPSHOT release.\n---\n\n\nThis PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).",
"mergeCommit": {
"oid": "9dda1a331d311d0a7643015cc9e6802548c8d943"
}
}
]
},
Expand All @@ -163,7 +187,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "e86984fb22ccc5eafb6c3d815851ade3463193da"
}
}
]
},
Expand Down
5 changes: 4 additions & 1 deletion test/fixtures/commits-since-page-2.json
Expand Up @@ -19,7 +19,10 @@
}
]
},
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure"
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure",
"mergeCommit": {
"oid": "959ee48c95f254300eb040c46ebdc8248317efe4"
}
}
]
},
Expand Down
50 changes: 40 additions & 10 deletions test/fixtures/commits-since.json
Expand Up @@ -15,7 +15,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "e6daec403626c9987c7af0d97b34f324cd84320a"
}
}
]
},
Expand All @@ -33,7 +36,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "b29149f890e6f76ee31ed128585744d4c598924c"
}
}
]
},
Expand All @@ -51,7 +57,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "27d7d7232e2e312d1380e906984f0823f5decf61"
}
}
]
},
Expand All @@ -69,7 +78,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "2b4e0b3be2e231cd87cc44c411bd8f84b4587ab5"
}
}
]
},
Expand All @@ -87,7 +99,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "a257514a541d483425118d973674b1ce006a5489"
}
}
]
},
Expand All @@ -105,7 +120,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "b6a8ab1a50106cfb03f22c2cdaf7abfdcccce088"
}
}
]
},
Expand All @@ -123,7 +141,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "520b6f42551c86002197d033564a76a3f99b0019"
}
}
]
},
Expand All @@ -145,7 +166,10 @@
}
]
},
"body": ":robot: I have created a release \\*beep\\* \\*boop\\* \n---\n### Updating meta-information for bleeding-edge SNAPSHOT release.\n---\n\n\nThis PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please)."
"body": ":robot: I have created a release \\*beep\\* \\*boop\\* \n---\n### Updating meta-information for bleeding-edge SNAPSHOT release.\n---\n\n\nThis PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).",
"mergeCommit": {
"oid": "9dda1a331d311d0a7643015cc9e6802548c8d943"
}
}
]
},
Expand All @@ -163,7 +187,10 @@
"labels": {
"nodes": []
},
"body": ""
"body": "",
"mergeCommit": {
"oid": "e86984fb22ccc5eafb6c3d815851ade3463193da"
}
}
]
},
Expand Down Expand Up @@ -192,7 +219,10 @@
}
]
},
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure"
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure",
"mergeCommit": {
"oid": "959ee48c95f254300eb040c46ebdc8248317efe4"
}
}
]
},
Expand Down
20 changes: 16 additions & 4 deletions test/fixtures/latest-tag-alternate-branch.json
Expand Up @@ -19,7 +19,10 @@
}
]
},
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure"
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure",
"mergeCommit": {
"oid": "bc329592af60713fe28586dc6d9dfb03aa2dbe1a"
}
}
]
},
Expand All @@ -41,7 +44,10 @@
}
]
},
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure"
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure",
"mergeCommit": {
"oid": "92af60713fe28586dc6d9dfb03aa2dbe1abc3295"
}
}
]
},
Expand All @@ -63,7 +69,10 @@
}
]
},
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure"
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure",
"mergeCommit": {
"oid": "959ee48c95f254300eb040c46ebdc8248317efe4"
}
}
]
},
Expand All @@ -85,7 +94,10 @@
}
]
},
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure"
"body": "This pull request was generated using releasetool.\n\n02-03-2021 11:56 PST\n\n### New Features\n- feat: initial commit\n\n### Internal / Testing Changes\n- build: add java structure",
"mergeCommit": {
"oid": "959ee48c95f254300eb040c46ebdc8248317efe4"
}
}
]
},
Expand Down

0 comments on commit c144f8b

Please sign in to comment.