Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use full length commit sha #299

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const config: CodegenConfig = {
skipTypename: true,
scalars: {
DateTime: 'string',
GitObjectID: 'string',
},
},
},
Expand Down
11 changes: 5 additions & 6 deletions dist/main.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/main.cjs.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'*.{js,ts,json,yml,md,mdx}': filenames =>
`prettier --write ${filenames.join(' ')}`,
'*.{js,ts,json}': () => 'pnpm run package',
}
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
"type": "module",
"author": "Balvajs",
"license": "MIT",
"lint-staged": {
"*.{js,ts,json,yml,md,mdx}": "prettier --write"
},
"devDependencies": {
"@actions/core": "1.10.1",
"@actions/github": "6.0.0",
Expand Down
5 changes: 2 additions & 3 deletions src/__generated__/get-pr-data.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/calculate-reviews-to-dismiss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type Review = {
login: string
} | null
commit: {
abbreviatedOid: string
oid: string
} | null
}

Expand Down Expand Up @@ -95,10 +95,10 @@ export const calculateReviewToDismiss = async <TReview extends Review>({
let isDismissed = false

console.log(
`Considering review from ${author?.login} and file changes between ${review.commit?.abbreviatedOid} (reviewed commit) and ${headCommit} (head commit)`,
`Considering review from ${author?.login} and file changes between ${review.commit?.oid} (reviewed commit) and ${headCommit} (head commit)`,
)

if (review.commit?.abbreviatedOid === headCommit) {
if (review.commit?.oid === headCommit) {
console.log(
'The review commit sha is the same as head commit sha and changed files can’t be resolved. This is caused by force-push.',
)
Expand Down
3 changes: 1 addition & 2 deletions src/get-pr-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const getPullRequestQuery = /* GraphQL */ `
nodes {
commit {
oid
abbreviatedOid
committedDate
}
}
Expand All @@ -25,7 +24,7 @@ const getPullRequestQuery = /* GraphQL */ `
id
state
commit {
abbreviatedOid
oid
}
author {
__typename
Expand Down
4 changes: 2 additions & 2 deletions src/group-reviews-by-commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Review = {
login: string
} | null
commit: {
abbreviatedOid: string
oid: string
} | null
}

Expand All @@ -40,7 +40,7 @@ export const groupReviewsByCommit = async <TReview extends Review>({
> = {}
await Promise.all(
latestReviews.map(async review => {
const reviewCommit = review.commit?.abbreviatedOid as string
const reviewCommit = review.commit?.oid as string
const basehead = `${reviewCommit}..${headCommit}`

// if group exists, just push the review to the group
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const run = async () => {
try {
const reviewsToDismissContext = await calculateReviewToDismiss({
octokit,
headCommit: head.abbreviatedOid,
headCommit: head.oid,
latestReviews: latestApprovedReviews,
baseBranch: context.payload.pull_request?.base.ref as string,
ignoreFiles,
Expand Down
Loading