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

added complete once if possible, added jira integration #4

Merged
merged 4 commits into from
May 4, 2023

Conversation

ravilushqa
Copy link
Owner

@ravilushqa ravilushqa commented Apr 25, 2023

Description

This pull request adds the ability to integrate Jira tickets into pull request descriptions, and updates the completion logic based on the size of the diff. It also includes a new function and method in the jira package to extract and generate Jira ticket URLs.

Changes

  • Updated cmd/description/main.go to support adding Jira ticket URLs and update completion logic.
  • Added new function, ExtractJiraTicketID(), to jira/jira.go to extract the first Jira ticket ID from input strings.
  • Added new method, GenerateJiraTicketURL(), to jira/jira.go to generate the complete URL for a given Jira ticket ID.
  • Updated tests in jira/jira_test.go to cover multiple scenarios and added a new test case for lowercase ticket ID validation.

Files Changed

  • cmd/description/main.go
  • cmd/review/main.go
  • jira/jira.go
  • jira/jira_test.go

}

return nil
return overallCompletion, nil
}

Choose a reason for hiding this comment

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

The code patch adds a new flag JiraURL to the CLI and a new import package jira. The genCompletionOnce and genCompletionPerFile functions are refactored to accept an OpenAI client as an argument. The run function now checks for the Test flag and prints the completion output if it is set to true. A new genCompletionPerFile function is introduced to generate completion for files with diffs greater than 4000 bytes. The main function reads the JiraURL flag, checks for the Test flag, and calls the run function to update the pull request description.

The code looks easy to read, and the changes made seem reasonable. However, it is hard to tell if there are any bugs or risks without understanding the full context of the code and its usage. As for improvement suggestions, it would be helpful to add comments to explain the purpose and functionality of the added code. Additionally, error handling could be improved by providing more detailed error messages when returning errors.


func GenerateJiraTicketURL(jiraURL, ticketID string) string {
return fmt.Sprintf(ticketUrlFormat, jiraURL, ticketID)
}

Choose a reason for hiding this comment

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

This code patch adds functionality for extracting JIRA ticket IDs from a string and generating a JIRA URL for a given ticket ID. Overall, the code seems simple and straightforward.

One potential improvement could be to add more robust error handling for the GenerateJiraTicketURL function, such as checking that the JIRA URL string is not empty. Additionally, it may be helpful to add some documentation or comments to explain the purpose of the ticketUrlFormat constant.

Overall, the code seems low-risk for introducing bugs.

}
})
}
}

Choose a reason for hiding this comment

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

This code patch adds a test function for a ExtractJiraTicketID function implemented elsewhere. The test function contains multiple test cases to test the functionality of the ExtractJiraTicketID function in multiple scenarios. The test cases vary based on the input strings and the expected output.

Overall, the code patch looks good, and the testing strategy is quite comprehensive. However, one suggestion for improvement could be to include some edge cases, such as very long input strings or non-alphanumeric characters in the input string. Additionally, it might be a good idea to check for the error message in the test cases that expect an error to ensure that the correct type of error is being thrown.

@ravilushqa ravilushqa merged commit dedb187 into main May 4, 2023
@ravilushqa ravilushqa deleted the enhance_description branch May 7, 2023 08:30
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.

1 participant