mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-05 15:46:47 -07:00
feat(optimizer): improve process scripts to address stuck issues and stale PRs
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
try {
|
||||
const repoInfo = execSync('gh repo view --json nameWithOwner', { encoding: 'utf-8' });
|
||||
const repo = JSON.parse(repoInfo).nameWithOwner;
|
||||
const [owner, name] = repo.split('/');
|
||||
|
||||
const query = `query($endCursor: String) { repository(owner: "${owner}", name: "${name}") { pullRequests(states: MERGED, first: 100, after: $endCursor) { nodes { authorAssociation } pageInfo { hasNextPage endCursor } } } }`;
|
||||
|
||||
const command = `gh api graphql --paginate -f query='${query}' --jq '.data.repository.pullRequests.nodes[] | select(.authorAssociation != "MEMBER" and .authorAssociation != "OWNER" and .authorAssociation != "COLLABORATOR") | .authorAssociation' | wc -l`;
|
||||
|
||||
const output = execSync(command, { encoding: 'utf-8' });
|
||||
const completedCommunityPrs = parseInt(output.trim(), 10);
|
||||
|
||||
process.stdout.write(JSON.stringify({
|
||||
metric: 'completed_community_prs',
|
||||
value: completedCommunityPrs,
|
||||
timestamp: new Date().toISOString()
|
||||
}));
|
||||
} catch (err) {
|
||||
process.stderr.write(err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
try {
|
||||
const repoInfo = execSync('gh repo view --json nameWithOwner', { encoding: 'utf-8' });
|
||||
const repo = JSON.parse(repoInfo).nameWithOwner;
|
||||
const output = execSync(`gh search prs --state open --repo ${repo} --limit 1000 --json authorAssociation`, { encoding: 'utf-8' });
|
||||
const prs = JSON.parse(output);
|
||||
const communityPrs = prs.filter(pr =>
|
||||
pr.authorAssociation !== 'MEMBER' &&
|
||||
pr.authorAssociation !== 'OWNER' &&
|
||||
pr.authorAssociation !== 'COLLABORATOR'
|
||||
);
|
||||
process.stdout.write(JSON.stringify({
|
||||
metric: 'open_community_prs',
|
||||
value: communityPrs.length,
|
||||
timestamp: new Date().toISOString()
|
||||
}));
|
||||
} catch (err) {
|
||||
process.stderr.write(err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user