@@ -78,9 +78,11 @@ export function isExternalContributionMaybe(pullRequest) {
7878 // NONE: Author has no association with the repository (or doesn't want to make his association public).
7979 switch ( pullRequest . author_association . toUpperCase ( ) ) {
8080 case "OWNER" :
81+ pullRequest . isExternalContribution = false ;
8182 storage . cache . set ( false , username , "contribution" , "external" , owner , repo ) ;
8283 return false ;
8384 case "MEMBER" :
85+ pullRequest . isExternalContribution = false ;
8486 storage . cache . set ( false , username , "contribution" , "external" , owner , repo ) ;
8587 return false ;
8688 case "COLLABORATOR" :
@@ -93,12 +95,18 @@ export function isExternalContributionMaybe(pullRequest) {
9395 }
9496 }
9597 if ( pullRequest ?. head ?. repo ?. full_name !== pullRequest ?. base ?. repo ?. full_name ) {
98+ pullRequest . isExternalContribution = true ;
9699 storage . cache . set ( true , username , "contribution" , "external" , owner , repo ) ;
97100 return true ;
101+ } else if ( pullRequest ?. head ?. repo ?. full_name && pullRequest ?. base ?. repo ?. full_name ) {
102+ pullRequest . isExternalContribution = false ;
103+ storage . cache . set ( false , username , "contribution" , "external" , owner , repo ) ;
104+ return false ;
98105 }
99106 // Utilize cache if possible
100107 const isConfirmedToBeExternalContributionInPast = storage . cache . get ( username , "contribution" , "external" , owner , repo ) ;
101108 if ( typeof isConfirmedToBeExternalContributionInPast === "boolean" ) {
109+ pullRequest . isExternalContribution = isConfirmedToBeExternalContributionInPast ;
102110 return isConfirmedToBeExternalContributionInPast
103111 }
104112 // Ambigous results after this point.
@@ -521,7 +529,7 @@ async function isAllowedToWriteToTheRepo(octokit, username, owner, repo,) {
521529 // The app is not installed in that repo
522530 // Only "metadata:repository" permission is needed for this api, which all gh apps have wherever they are installed
523531 console . log ( "Failed to check if a " + username + " is allowed to write to " + owner + "/" + repo ) ;
524- console . error ( err ) ;
532+ // console.error(err);
525533 throw new Error ( "Failed to check user permission for the repo" )
526534 }
527535}
0 commit comments