Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gitlab support improvements #97

Merged
merged 3 commits into from
Aug 7, 2023
Merged

Conversation

gowoons
Copy link
Contributor

@gowoons gowoons commented Aug 7, 2023

  • Fixing README to use --setupTarget when using configure instead of --ci
  • Mask API key when setting up for gitlab
  • Change gitlab PR template

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2023

Risk Level 2 - /home/runner/work/code-review-gpt/code-review-gpt/src/configure/index.ts

The code is generally well-written and follows good practices. However, there are a few areas that could be improved for better error handling and code readability.

  1. Error Handling: The execSync function is used without any error handling mechanism. If the command fails, it will throw an error which is not caught. This can lead to unhandled promise rejections. It would be better to wrap the execSync calls in a try-catch block to handle potential errors.
try {
  execSync(`gh auth status || gh auth login`, { stdio: \"inherit\" });
  execSync(`gh secret set OPENAI_API_KEY --body=${apiKey}`);
} catch (error) {
  logger.error('Error executing command', error);
}
  1. Code Duplication: The code for prompting the user for the API key is duplicated in both configureGitHub and configureGitLab functions. This could be extracted into a separate function to avoid code duplication.
const promptForApiKey = async () => {
  const inquirer = await import(\"inquirer\");
  const { apiKey } = await inquirer.default.prompt([
    {
      type: \"input\",
      name: \"apiKey\",
      message: \"Please input your OpenAI API key:\",
      mask: \"*\",
    },
  ]);
  return apiKey;
};

Then you can use this function in both configureGitHub and configureGitLab functions.

const apiKey = await promptForApiKey();

👍🔧🔂


Powered by Code Review GPT

@gowoons gowoons force-pushed the fix/gitlab-support-improvements branch from 0838bde to 3f7fa01 Compare August 7, 2023 10:31
@gowoons gowoons marked this pull request as ready for review August 7, 2023 10:33
@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2023

Test results summary:

✅ [PASS] - Test case: Bad variable name
✅ [PASS] - Test case: Exposed secret
✅ [PASS] - Test case: Too many nested loops
✅ [PASS] - Test case: Unawaited Promise

SUMMARY: ✅ PASS: 4 - ⚠️ WARN: 0 - ❌ FAIL: 0


Tests Powered by Code Review GPT

@@ -77,6 +77,7 @@ const configureGitLab = async () => {
type: "input",
name: "apiKey",
message: "Please input your OpenAI API key:",
mask: "*",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niceee

@mattzcarey mattzcarey merged commit a5c7d6b into main Aug 7, 2023
@mattzcarey mattzcarey deleted the fix/gitlab-support-improvements branch August 7, 2023 10:51
This was referenced Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants