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

Revert "Refactor" #21

Merged
merged 1 commit into from
May 7, 2023
Merged

Revert "Refactor" #21

merged 1 commit into from
May 7, 2023

Conversation

ravilushqa
Copy link
Owner

@ravilushqa ravilushqa commented May 7, 2023

Description

This pull request reverts the changes made in #18.

Changes

.github/workflows/golangci-lint.yml

  • Added golangci-lint GitHub action to perform linting on push and pull requests. The action runs on Ubuntu latest and uses golangci/golangci-lint-action@v3 with version v1.52. Optional arguments include working directory, command line arguments, and caching options. Pull requests can also show only new issues with the only-new-issues option.

.github/workflows/gpt_pullrequest_updater.yml

  • Updated the build process to use "go build" instead of "make build" and added separate build commands for "description" and "review". Also updated the paths for the executables in the subsequent steps. Finally, added environment variables for GitHub and OpenAI tokens. If a pull request is opened, the "review" command will be executed.

.gitignore

  • Removed unnecessary files from the repository.

.golangci.yaml

  • This code patch updates the linters configuration to specifically enable the desired linters and disable all others. It also excludes certain rules for issues in test files. Additionally, it sets specific settings for the misspell and goimports linters.

Makefile

  • Added build command to compile binaries for description and review. Also added init-tools command to install development tools. Lint command runs golangci-lint and test command runs go test. Added precommit command to run lint and test before committing. Help command shows available targets.

README.md

  • Updated the build process to use "go build" instead of "make build" and added separate build commands for description and review. Also updated the paths for the description and review executables in the "Update Pull Request Description" and "Review Pull Request" steps respectively. This should improve the build process and ensure that the correct executables are being used.

cmd/review/config.go

  • Added options for GitHub token, OpenAI token, GitHub owner, GitHub repo, Pull request number, and test mode to the main package. These options are required for the program to function properly.

cmd/review/main.go

  • Refactor the code to use a separate function for processing files and creating comments. The function takes in the necessary parameters and returns the comments to be pushed to the pull request. Remove the opts struct and related flags as they are no longer needed.

cmd/review/review.go

  • Refactored the code to change the package name to main and added new dependencies. Also, renamed the function GenerateCommentsFromDiff to processFiles and removed the interfaces PullRequestUpdater and Completer. The function createComments was also modified to use the new ghClient package instead of the old interface.

cmd/review/utils.go

  • Changed package name from "review" to "main" to follow Go naming conventions. Also added import for encoding/json.

cmd/review/utils_test.go

  • Refactored package name from "review" to "main" to better reflect the purpose of the code. No changes were made to the functionality of the code.

go.mod

  • Removed unnecessary dependencies from the code patch.

go.sum

  • Updated dependencies:

    • github.com/cloudflare/circl v1.1.0
    • github.com/golang/protobuf v1.5.2
    • google.golang.org/protobuf v1.28.0
  • Removed dependencies:

    • github.com/davecgh/go-spew v1.1.0/go.mod
    • github.com/davecgh/go-spew v1.1.1
    • github.com/davecgh/go-spew v1.1.1/go.mod
    • github.com/pmezard/go-difflib v1.0.0
    • github.com/pmezard/go-difflib v1.0.0/go.mod
    • github.com/stretchr/objx v0.1.0/go.mod
    • github.com/stretchr/objx v0.4.0/go.mod
    • github.com/stretchr/objx v0.5.0
    • github.com/stretchr/objx v0.5.0/go.mod
    • github.com/stretchr/testify v1.7.1/go.mod
    • github.com/stretchr/testify v1.8.0/go.mod
    • github.com/stretchr/testify v1.8.2
    • github.com/stretchr/testify v1.8.2/go.mod
    • gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
    • gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod
    • gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod
    • gopkg.in/yaml.v3 v3.0.1
    • gopkg.in/yaml.v3 v3.0.1/go.mod
  • Added dependencies:

    • github.com/bwesterb/go-ristretto v1.2.0/go.mod
    • github.com/google/go-querystring v1.1.0
    • github.com/google/go-querystring v1.1.0/go.mod
    • github.com/jessevdk/go-flags v1.5.0
    • github.com/jessevdk/go-flags v1.5.0/go.mod
    • github.com/sashabaranov/go-openai v1.7.0
    • github.com/sashabaranov/go-openai v1.7.0/go.mod
    • github.com/stretchr/testify v1.7.1
    • github.com/stretchr/testify v1.7.1/go.mod
    • github.com/stretchr/testify v1.8.0
    • github.com/stretchr/testify v1.8.0/go.mod
    • gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod

jira/jira.go

  • Fix typo in ticket URL format constant and function name. This patch fixes a typo in the ticket URL format constant, changing "ticketURLFormat" to "ticketUrlFormat". It also updates the corresponding function name, "GenerateJiraTicketURL", to use the corrected constant. This change ensures consistency and accuracy in the codebase.

openai/openai.go

  • Updated the embedded file path in the code from "prompts/review" to "prompt-review.txt" to match the actual file name. This change ensures that the correct file is being accessed and used in the code.

review/review_test.go

  • Refactor code to improve testing and readability. This pull request refactors the code to improve testing and readability. It introduces two mock structs, MockCompleter and MockPullRequestUpdater, to enable unit testing of the GenerateCommentsFromDiff and PushComments functions. It also adds test cases to cover different scenarios for these functions. Additionally, the code has been cleaned up to improve readability and maintainability. The ptrOf function has been added to simplify the creation of pointers to values.

tools/go.mod

  • Removed unused module and updated dependencies in go.mod file.

tools/go.sum

  • Removed outdated dependencies and updated some Google Cloud dependencies to their latest versions. Also added a new dependency for detecting duplicate words.

tools/tools.go

  • Removed unnecessary build tag and updated go generate command to build golangci-lint in bin directory.

@ravilushqa ravilushqa merged commit c6d76ad into main May 7, 2023
@ravilushqa ravilushqa deleted the revert-18-refactor branch May 7, 2023 17:17
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