@@ -14,7 +14,7 @@ if (!githubToken) {
1414// Initialize Octokit with your GitHub token
1515const octokit = new Octokit ( { auth : githubToken } ) ;
1616
17- // https://github.com/MetaMask/MetaMask-planning/blob/main/teams .json lookup from here
17+ // https://github.com/MetaMask/MetaMask-planning/blob/main/topology .json lookup from here
1818async function getTeam ( repository , prNumber ) {
1919 try {
2020 const { data : prData } = await octokit . pulls . get ( {
@@ -25,29 +25,38 @@ async function getTeam(repository, prNumber) {
2525
2626 const author = prData . user . login ; // PR author's GitHub username
2727
28- const teamsJsonUrl =
29- 'https://raw.githubusercontent.com/MetaMask/MetaMask-planning/refs/heads/main/teams .json' ;
28+ const topologyJsonUrl =
29+ 'https://raw.githubusercontent.com/MetaMask/MetaMask-planning/refs/heads/main/topology .json' ;
3030 const githubToken = process . env . GITHUB_TOKEN ;
3131
32- const response = await axios . get ( teamsJsonUrl , {
32+ const response = await axios . get ( topologyJsonUrl , {
3333 headers : { Authorization : `token ${ githubToken } ` } ,
3434 } ) ;
3535
3636 // Check if the response is successful and contains data
3737 if ( response . status !== 200 || ! response . data ) {
3838 console . error (
39- `Invalid response when fetching teams .json: ${ response . status } ` ,
39+ `Invalid response when fetching topology .json: ${ response . status } ` ,
4040 ) ;
4141 return [ 'Unknown' ] ;
4242 }
4343
44- const teamsJson = response . data ;
44+ const topologyJson = response . data ;
4545
46- // Step 3: Match the PR author's username to a team
47- const team = teamsJson [ author ] ;
46+ // Search through teams to find the author in members, pm, em, or tl
47+ for ( const [ teamKey , teamData ] of Object . entries ( topologyJson ) ) {
48+ // Check if author is in members array
49+ if ( teamData . members && teamData . members . includes ( author ) ) {
50+ return teamKey ;
51+ }
52+ // Check if author is pm, em, or tl
53+ if ( teamData . pm === author || teamData . em === author || teamData . tl === author ) {
54+ return teamKey ;
55+ }
56+ }
4857
49- // Step 4: Return the team name or 'Unknown' if not found
50- return team || 'Unknown' ;
58+ // Return 'Unknown' if author not found in any team
59+ return 'Unknown' ;
5160
5261 } catch ( error ) {
5362 console . error (
0 commit comments