Skip to content

Commit 86d94e4

Browse files
authored
Compare submissions against their merge base (#973)
1 parent 13ea252 commit 86d94e4

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎src/plugins/pull_request.opened.default.ts‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ export default async (
109109
return
110110
}
111111

112-
const changedRepos = await getFileDiff(bot, payload, repoCategory || '')
112+
const changedRepos = await getFileDiff(
113+
bot,
114+
payload,
115+
repoCategory || '',
116+
comparison.merge_base_commit.sha,
117+
)
113118
if (changedRepos.length > 1) {
114119
if (payload.pull_request.additions > 1) {
115120
issues.push(
@@ -245,12 +250,19 @@ async function getChangedFiles(
245250
return listFilesResponse.map((file) => file.filename)
246251
}
247252

248-
async function getFileDiff(bot: GitHubBot, payload: PullPayload, file: string) {
253+
async function getFileDiff(
254+
bot: GitHubBot,
255+
payload: PullPayload,
256+
file: string,
257+
mergeBase: string,
258+
) {
259+
// Compared with where the branch started, not with master right now, which
260+
// can already hold the entries of other pull requests merged since
249261
const { data: currentContentData } =
250262
await bot.github.octokit.rest.repos.getContent({
251263
...extractOwnerRepo(payload),
252-
pull_number: payload.pull_request.number,
253264
path: file,
265+
ref: mergeBase,
254266
})
255267

256268
if (!('content' in currentContentData)) throw Error('No content')

0 commit comments

Comments
 (0)