Skip to content

Commit

Permalink
Corrected comments throughout the repository.
Browse files Browse the repository at this point in the history
  • Loading branch information
pacificbelt30 committed Jun 17, 2024
1 parent 1226bbd commit a4ef34e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func main() {
log.Ldate|log.Ltime|log.Llongfile|log.Lmsgprefix,
)

// Pre-define variables for error handling
var err error

// Read the configuration file
Expand All @@ -42,10 +43,10 @@ func main() {
logger.Fatalf("Error creating comment: %s", err)
}

// Create GitHub Issues instance
// Create a GitHub Issues instance. From now on, you can control GitHub from this instance.
issue := github.NewIssue(*owner, *repo, *issueNumber, *gh_token)

// Get Issue's info
// Get Issue's information(e.g. Title, Body) and add them to the user prompt except for comments by Actions.
title, _ := issue.GetTitle()
body, _ := issue.GetBody()
if cfg.System.Debug.Log_level == "debug" {
Expand All @@ -55,6 +56,7 @@ func main() {
user_prompt := "Title:" + *title + "\n"
user_prompt += "Body:" + *body + "\n"

// Get comments under the Issue and add them to the user prompt except for comments by Actions.
comments, _ := issue.GetComments()
for _, v := range comments {
if *v.User.Login == "github-actions[bot]" {
Expand Down
1 change: 1 addition & 0 deletions internal/ai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func NewOpenAIClient(apiKey string, model string) *OpenAI {
fmt.Println("Error: OPENAI_API_KEY environment variable not set.")
return nil
}

// Specifying the model to use
return &OpenAI{
apiKey: apiKey,
Expand Down
2 changes: 2 additions & 0 deletions internal/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type GitHubIssues struct {
}

func (gh *GitHubIssues) GetIssue() (*github.Issue, error) {
// Only the first call retrieves information from GitHub, all other calls use cache
if gh.cache == nil {
issue, _, err := gh.client.Issues.Get(gh.ctx, gh.owner, gh.repo, gh.issueNumber)
if err != nil {
Expand Down Expand Up @@ -82,6 +83,7 @@ func NewIssue(owner string, repo string, issueNumber int, token string) *GitHubI
log.Ldate|log.Ltime|log.Llongfile|log.Lmsgprefix,
)

// Create a new GitHubIssues instance
issue := &GitHubIssues{owner: owner, repo: repo, issueNumber: issueNumber, token: token, client: client, ctx: ctx, logger: logger}
return issue
}
2 changes: 2 additions & 0 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/viper"
)

// Root structure of information read from config file
type Config struct {
System System `yaml:"system"`
Ai Ai `yaml:"ai"`
Expand Down Expand Up @@ -54,6 +55,7 @@ func NewConfig(filename string) (*Config, error) {
// Get the directory and file name from variable filename
dir, file := filepath.Split(filename)
base, ext := filepath.Base(file)[:len(filepath.Base(file))-len(filepath.Ext(file))], filepath.Ext(file)[1:]

// Read the config file
viper.SetConfigName(base)
viper.SetConfigType(ext)
Expand Down

0 comments on commit a4ef34e

Please sign in to comment.