Skip to content

Commit

Permalink
Add name check
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Sep 26, 2023
1 parent ee93346 commit c0ad022
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/plugins/newDefaultOpened.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export default async (app: App, payload: PullPayload): Promise<void> => {
return
}

const repoCategory = changedFiles.filter((filename) => defaultCategories.includes(filename)).pop()
const repoCategory = changedFiles
.filter((filename) => defaultCategories.includes(filename))
.pop()
if (
!repoCategory ||
![
Expand Down Expand Up @@ -63,6 +65,9 @@ export default async (app: App, payload: PullPayload): Promise<void> => {
const owner = newRepo.split('/')[0]
const repo = newRepo.split('/')[1]

if (!owner || !repo) {
return
}
if (
repo.toLowerCase().includes('hacs') &&
payload.pull_request.review_comments === 0
Expand All @@ -76,6 +81,18 @@ export default async (app: App, payload: PullPayload): Promise<void> => {
return
}

const { data: repoInfo } = await app.octokit.rest.repos.get({ owner, repo })

if (repoInfo.full_name !== newRepo) {
await app.octokit.rest.pulls.createReview({
...extractOwnerRepo(payload),
pull_number: payload.pull_request.number,
event: 'REQUEST_CHANGES',
body: `The submitted name \`${newRepo}\` does not match what GitHub returns for the repository (\`${repoInfo.full_name}\`).`,
})
return
}

await app.octokit.rest.issues.addLabels({
...extractOwnerRepo(payload),
issue_number: payload.pull_request.number,
Expand All @@ -101,8 +118,7 @@ async function getChangedFiles(
...extractOwnerRepo(payload),
pull_number: payload.pull_request.number,
})
return listFilesResponse
.map((file) => file.filename)
return listFilesResponse.map((file) => file.filename)
}

async function getFileDiff(app: App, payload: PullPayload, file: string) {
Expand Down

0 comments on commit c0ad022

Please sign in to comment.