Skip to content

Commit

Permalink
ci: update compare regex
Browse files Browse the repository at this point in the history
  • Loading branch information
tlvince committed Jan 23, 2025
1 parent 703a5e2 commit eae1418
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions .github/scripts/compare.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
const generateCompareLinks = (flakeUpdateOutput) => {
const generateCompareLinks = (input) => {
// DeepSeek-R1 generated
const regex =
/'(?<repo>[^']+)':\s*'[^']*?(?:rev=|\/)(?<oldCommit>[a-f0-9]+)[^']*'\s*\(.*?\)\s*\s*'[^']*?(?:rev=|\/)(?<newCommit>[a-f0-9]+)[^']*'/gm;
/(?:'github:(?<repo1>[^/]+\/[^/]+)\/(?<oldCommit1>[0-9a-fA-F]{40})[^']*'|'git\+https:\/\/github\.com\/(?<repo2>[^/]+\/[^/]+)\?[^']*rev=(?<oldCommit2>[0-9a-fA-F]{40})[^']*')[\s\S]*?[\s\S]*?(?:'github:[^/]+\/[^/]+\/(?<newCommit1>[0-9a-fA-F]{40})[^']*'|'git\+https:\/\/github\.com\/[^/]+\/[^/]+\?[^']*rev=(?<newCommit2>[0-9a-fA-F]{40})[^']*')/g;

let match;
const links = [];
let match;

while ((match = regex.exec(input)) !== null) {
const groups = match.groups;
const repo = groups.repo1 || groups.repo2;
const oldCommit = groups.oldCommit1 || groups.oldCommit2;
const newCommit = groups.newCommit1 || groups.newCommit2;

while ((match = regex.exec(flakeUpdateOutput)) !== null) {
const { repo, oldCommit, newCommit } = match.groups;
const compareUrl = `https://github.com/${repo}/compare/${oldCommit}...${newCommit}`;
links.push(compareUrl);
if (repo && oldCommit && newCommit) {
const compareUrl = `https://github.com/${repo}/compare/${oldCommit}...${newCommit}`;
links.push(compareUrl);
}
}

return links;
Expand Down

0 comments on commit eae1418

Please sign in to comment.