Skip to content

Commit

Permalink
Upgrade to Go 1.21 (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
seachicken authored Feb 24, 2024
1 parent c632ffd commit 4e6d72f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
12 changes: 2 additions & 10 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"regexp"
"slices"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -188,7 +189,7 @@ func extractMergedBranchNames(mergedNames []string) []string {
func applyMerged(branches []shared.Branch, mergedNames []string) []shared.Branch {
results := []shared.Branch{}
for _, branch := range branches {
branch.IsMerged = nameExists(branch.Name, mergedNames)
branch.IsMerged = slices.Contains(mergedNames, branch.Name)
results = append(results, branch)
}
return results
Expand Down Expand Up @@ -669,15 +670,6 @@ func BranchNameExists(branchName string, branches []shared.Branch) bool {
return false
}

func nameExists(name string, names []string) bool {
for _, n := range names {
if n == name {
return true
}
}
return false
}

func SplitLines(text string) []string {
return strings.FieldsFunc(strings.Replace(text, "\r\n", "\n", -1),
func(c rune) bool { return c == '\n' })
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/seachicken/gh-poi

go 1.19
go 1.21

require (
github.com/briandowns/spinner v1.18.1
Expand Down
12 changes: 2 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"os/signal"
"slices"
"time"

"github.com/briandowns/spinner"
Expand Down Expand Up @@ -247,18 +248,9 @@ func getIssueNoColor(state shared.PullRequestState, isDraft bool) color.Attribut
func getBranches(branches []shared.Branch, states []shared.BranchState) []shared.Branch {
results := []shared.Branch{}
for _, branch := range branches {
if contains(branch.State, states) {
if slices.Contains(states, branch.State) {
results = append(results, branch)
}
}
return results
}

func contains(state shared.BranchState, states []shared.BranchState) bool {
for _, s := range states {
if s == state {
return true
}
}
return false
}
5 changes: 5 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func onlyCI(t *testing.T) {
}

func captureOutput(f func()) string {
org := os.Stdout
defer func() {
os.Stdout = org
}()

r, w, _ := os.Pipe()
os.Stdout = w
color.Output = w
Expand Down

0 comments on commit 4e6d72f

Please sign in to comment.