mirror of
				https://github.com/freeedcom/ai-codereviewer.git
				synced 2025-11-04 08:00:52 +00:00 
			
		
		
		
	attempt to fix the malformed request
This commit is contained in:
		
					parent
					
						
							
								903cfb745e
							
						
					
				
			
			
				commit
				
					
						dbf427f89f
					
				
			
		
					 3 changed files with 22 additions and 13 deletions
				
			
		
							
								
								
									
										17
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -211,23 +211,28 @@ function main() {
 | 
				
			||||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
					    return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
        const prDetails = yield getPRDetails();
 | 
					        const prDetails = yield getPRDetails();
 | 
				
			||||||
        const { baseSha, headSha } = yield getBaseAndHeadShas(prDetails.owner, prDetails.repo, prDetails.pull_number);
 | 
					        const { baseSha, headSha } = yield getBaseAndHeadShas(prDetails.owner, prDetails.repo, prDetails.pull_number);
 | 
				
			||||||
        let diffUrl;
 | 
					        let diff;
 | 
				
			||||||
        if (process.env.GITHUB_EVENT_NAME === "pull_request") {
 | 
					        if (process.env.GITHUB_EVENT_NAME === "pull_request") {
 | 
				
			||||||
            diffUrl = yield getDiff(prDetails.owner, prDetails.repo, prDetails.pull_number);
 | 
					            diff = yield getDiff(prDetails.owner, prDetails.repo, prDetails.pull_number);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (process.env.GITHUB_EVENT_NAME === "push") {
 | 
					        else if (process.env.GITHUB_EVENT_NAME === "push") {
 | 
				
			||||||
            diffUrl = yield getChangedFiles(prDetails.owner, prDetails.repo, baseSha, headSha);
 | 
					            const diffUrl = yield getChangedFiles(prDetails.owner, prDetails.repo, baseSha, headSha);
 | 
				
			||||||
 | 
					            if (diffUrl) {
 | 
				
			||||||
 | 
					                const diffResponse = yield octokit.request({ url: diffUrl });
 | 
				
			||||||
 | 
					                diff = diffResponse.data;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else {
 | 
				
			||||||
 | 
					                diff = null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
 | 
					            console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!diffUrl) {
 | 
					        if (!diff) {
 | 
				
			||||||
            console.log("No diff found");
 | 
					            console.log("No diff found");
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const diffResponse = yield octokit.request({ url: diffUrl });
 | 
					 | 
				
			||||||
        const diff = diffResponse.data;
 | 
					 | 
				
			||||||
        const parsedDiff = (0, parse_diff_1.default)(diff);
 | 
					        const parsedDiff = (0, parse_diff_1.default)(diff);
 | 
				
			||||||
        const excludePatterns = core
 | 
					        const excludePatterns = core
 | 
				
			||||||
            .getInput("exclude")
 | 
					            .getInput("exclude")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2
									
								
								dist/index.js.map
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/index.js.map
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										16
									
								
								src/main.ts
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								src/main.ts
									
										
									
									
									
								
							| 
						 | 
					@ -216,33 +216,37 @@ async function main() {
 | 
				
			||||||
    prDetails.pull_number
 | 
					    prDetails.pull_number
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let diffUrl: string | null;
 | 
					  let diff: string | null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (process.env.GITHUB_EVENT_NAME === "pull_request") {
 | 
					  if (process.env.GITHUB_EVENT_NAME === "pull_request") {
 | 
				
			||||||
    diffUrl = await getDiff(
 | 
					    diff = await getDiff(
 | 
				
			||||||
      prDetails.owner,
 | 
					      prDetails.owner,
 | 
				
			||||||
      prDetails.repo,
 | 
					      prDetails.repo,
 | 
				
			||||||
      prDetails.pull_number
 | 
					      prDetails.pull_number
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  } else if (process.env.GITHUB_EVENT_NAME === "push") {
 | 
					  } else if (process.env.GITHUB_EVENT_NAME === "push") {
 | 
				
			||||||
    diffUrl = await getChangedFiles(
 | 
					    const diffUrl = await getChangedFiles(
 | 
				
			||||||
      prDetails.owner,
 | 
					      prDetails.owner,
 | 
				
			||||||
      prDetails.repo,
 | 
					      prDetails.repo,
 | 
				
			||||||
      baseSha,
 | 
					      baseSha,
 | 
				
			||||||
      headSha
 | 
					      headSha
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					    if (diffUrl) {
 | 
				
			||||||
 | 
					      const diffResponse = await octokit.request({ url: diffUrl });
 | 
				
			||||||
 | 
					      diff = diffResponse.data;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      diff = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
 | 
					    console.log("Unsupported event:", process.env.GITHUB_EVENT_NAME);
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!diffUrl) {
 | 
					  if (!diff) {
 | 
				
			||||||
    console.log("No diff found");
 | 
					    console.log("No diff found");
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const diffResponse = await octokit.request({ url: diffUrl });
 | 
					 | 
				
			||||||
  const diff = diffResponse.data;
 | 
					 | 
				
			||||||
  const parsedDiff = parseDiff(diff);
 | 
					  const parsedDiff = parseDiff(diff);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const excludePatterns = core
 | 
					  const excludePatterns = core
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue