Skip to content

Commit

Permalink
Fix a redundant passing of internalteam var and rename the config str…
Browse files Browse the repository at this point in the history
…uct that is passed in CheckforPendingCI
  • Loading branch information
pmaslana committed May 31, 2024
1 parent c323c36 commit 4d7d8df
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/labelPRs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var labelPRsCmd = &cobra.Command{
loopDuration := viper.GetDuration("loop-time")
for {
log.Println("Labeling Pull Requests")
err = label.PullRequests(client, cfg.InternalTeam, cfg)
err = label.PullRequests(client, cfg)
if err != nil {
log.Fatalln(err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/notifyPendingCI.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var notifyPendingCICmd = &cobra.Command{
var listPendingPRs []string
for {
log.Println("Checking for community PRs that are waiting for CI to run")
listPendingPRs, err = github2.CheckForPendingCI(client, cfg.InternalTeam, cfg)
listPendingPRs, err = github2.CheckForPendingCI(client, cfg)
if err != nil {
log.Printf("The following error occurred while obtaining a list of pending PRs: %s", err)
time.Sleep(loopDuration)
Expand Down
2 changes: 1 addition & 1 deletion cmd/notifyStale.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var notifyStaleCmd = &cobra.Command{
var listPendingPRs []string
for {
log.Println("Checking for community PRs that have no update in the last 7 days")
_, err = github2.CheckStalePRs(client, cfg.InternalTeam, cfg)
_, err = github2.CheckStalePRs(client, cfg)
if err != nil {
log.Printf("The following error occurred while obtaining a list of stale PRs: %s", err)
time.Sleep(loopDuration)
Expand Down
8 changes: 4 additions & 4 deletions internal/github/checkPendingCI.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
)

// CheckForPendingCI returns a list of PR URLs that are ready for CI to run but haven't started yet.
func CheckForPendingCI(githubClient *github.Client, internalTeam string, repos *config.Config) ([]string, error) {
teamMembers, _ := GetTeamMemberList(githubClient, internalTeam)
func CheckForPendingCI(githubClient *github.Client, cfg *config.Config) ([]string, error) {
teamMembers, _ := GetTeamMemberList(githubClient, cfg.InternalTeam)
var pendingPRs []string

for _, fullRepo := range repos.CheckRepos {
for _, fullRepo := range cfg.CheckRepos {
log.Println("Checking repository:", fullRepo.Name)
parts := strings.Split(fullRepo.Name, "/")
if len(parts) != 2 {
Expand All @@ -28,7 +28,7 @@ func CheckForPendingCI(githubClient *github.Client, internalTeam string, repos *
owner, repo := parts[0], parts[1]

// Fetch community PRs using the FindCommunityPRs function
communityPRs, err := FindCommunityPRs(repos, teamMembers, githubClient)
communityPRs, err := FindCommunityPRs(cfg, teamMembers, githubClient)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/github/checkStalePRs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
)

// CheckStalePRs will return a list of PR URLs that have not been updated in the last 7 days by internal team members.
func CheckStalePRs(githubClient *github.Client, internalTeam string, cfg *config.Config) ([]string, error) {
func CheckStalePRs(githubClient *github.Client, cfg *config.Config) ([]string, error) {
var stalePRUrls []string
cutoffDate := time.Now().Add(7 * 24 * time.Hour) // 7 days ago
teamMembers, err := GetTeamMemberList(githubClient, internalTeam)
teamMembers, err := GetTeamMemberList(githubClient, cfg.InternalTeam)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/label/pullrequests.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
)

// PullRequests applies internal or community labels to pull requests
func PullRequests(githubClient *github.Client, internalTeam string, cfg *config.Config) error {
teamMembers, err := github2.GetTeamMemberList(githubClient, internalTeam)
func PullRequests(githubClient *github.Client, cfg *config.Config) error {
teamMembers, err := github2.GetTeamMemberList(githubClient, cfg.InternalTeam)
if err != nil {
return fmt.Errorf("error getting team members: %w", err) // Properly handle and return error if team member list fetch fails
}
Expand Down

0 comments on commit 4d7d8df

Please sign in to comment.