Skip to content

Commit

Permalink
Merge pull request AsherGlick#385 from klingbolt/proto_differ_checker
Browse files Browse the repository at this point in the history
Proto differ checker
  • Loading branch information
AsherGlick authored Feb 6, 2025
2 parents e1080fd + 93c798f commit adf04a0
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion .github/workflows/diff_protobin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
touch $file.textproto._new
fi
diff -u $file.textproto._old $file.textproto._new > $file._diff || true
diff -u $file.textproto._old --label old $file.textproto._new --label new > $file._diff || true
echo $file >> file_list.txt
done
Expand All @@ -68,12 +68,29 @@ jobs:
const issue_number = context.issue.number;
const githubToken = process.env.GITHUB_TOKEN;
// Get the existing comments.
const {data: comments} = await github.rest.pulls.listReviewComments({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: issue_number,
});
const files = fs.readFileSync('file_list.txt', 'utf8').split("\n");
for (let file of files) {
if (file == "") {
continue;
}
// Filter comments related to the current file
const file_comments = comments.filter(comment => comment.path === file);
// Sort comments by creation date in descending order
file_comments.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
// Get the most recent comment
const most_recent_comment = file_comments.length > 0 ? file_comments[0] : null;
const diff_contents = fs.readFileSync(file + "._diff", 'utf8')
let comment_body = [
"<details>",
Expand All @@ -85,6 +102,12 @@ jobs:
"</details>",
].join("\n");
// Check if a similar comment already exists
if (most_recent_comment && most_recent_comment.body === comment_body) {
console.log(`Skipping file ${file}, identical comment already exists.`);
continue;
}
console.log(file)
await github.rest.pulls.createReviewComment({
Expand Down

0 comments on commit adf04a0

Please sign in to comment.