Skip to content

Commit a71d288

Browse files
authored
do not query unassesary (#159)
1 parent 064f970 commit a71d288

File tree

10 files changed

+98
-218
lines changed

10 files changed

+98
-218
lines changed

go.mod

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
module github.com/fullstack-devops/awesome-ci
22

3-
go 1.20
3+
go 1.21
44

55
require (
66
github.com/coreos/go-semver v0.3.1
77
github.com/ghodss/yaml v1.0.0
8-
github.com/go-git/go-git/v5 v5.7.0
9-
github.com/google/go-github/v53 v53.2.0
8+
github.com/go-git/go-git/v5 v5.10.0
9+
github.com/google/go-github/v56 v56.0.0
1010
github.com/itchyny/gojq v0.12.13
11-
github.com/spf13/cobra v1.7.0
12-
github.com/xanzy/go-gitlab v0.86.0
13-
golang.org/x/oauth2 v0.10.0
11+
github.com/spf13/cobra v1.8.0
12+
github.com/xanzy/go-gitlab v0.93.2
13+
golang.org/x/oauth2 v0.13.0
1414
gopkg.in/yaml.v2 v2.4.0
1515
)
1616

1717
require (
18-
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
18+
dario.cat/mergo v1.0.0 // indirect
19+
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
20+
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
1921
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
2022
github.com/inconshreveable/mousetrap v1.1.0 // indirect
2123
github.com/itchyny/timefmt-go v0.1.5 // indirect
22-
github.com/kr/pretty v0.3.1 // indirect
2324
github.com/russross/blackfriday/v2 v2.1.0 // indirect
2425
github.com/spf13/pflag v1.0.5 // indirect
2526
gopkg.in/yaml.v3 v3.0.1 // indirect
2627
)
2728

2829
require (
2930
github.com/Microsoft/go-winio v0.6.1 // indirect
30-
github.com/ProtonMail/go-crypto v0.0.0-20230626094100-7e9e0395ebec // indirect
31+
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect
3132
github.com/acomagu/bufpipe v1.0.4 // indirect
32-
github.com/cloudflare/circl v1.3.3 // indirect
33+
github.com/cloudflare/circl v1.3.6 // indirect
3334
github.com/emirpasic/gods v1.18.1 // indirect
3435
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
35-
github.com/go-git/go-billy/v5 v5.4.1 // indirect
36+
github.com/go-git/go-billy/v5 v5.5.0 // indirect
3637
github.com/golang/protobuf v1.5.3 // indirect
3738
github.com/google/go-querystring v1.1.0 // indirect
3839
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
3940
github.com/hashicorp/go-hclog v1.4.0 // indirect
4041
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
41-
github.com/imdario/mergo v0.3.16 // indirect
4242
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
4343
github.com/kevinburke/ssh_config v1.2.0 // indirect
4444
github.com/mattn/go-colorable v0.1.13 // indirect
4545
github.com/pjbgf/sha1cd v0.3.0 // indirect
4646
github.com/sergi/go-diff v1.3.1 // indirect
4747
github.com/sirupsen/logrus v1.9.3
48-
github.com/skeema/knownhosts v1.1.1 // indirect
48+
github.com/skeema/knownhosts v1.2.1 // indirect
4949
github.com/xanzy/ssh-agent v0.3.3 // indirect
50-
golang.org/x/crypto v0.11.0 // indirect
51-
golang.org/x/mod v0.12.0 // indirect
52-
golang.org/x/net v0.12.0 // indirect
53-
golang.org/x/sys v0.10.0 // indirect
54-
golang.org/x/time v0.3.0 // indirect
55-
golang.org/x/tools v0.11.0 // indirect
56-
google.golang.org/appengine v1.6.7 // indirect
50+
golang.org/x/crypto v0.14.0 // indirect
51+
golang.org/x/mod v0.14.0 // indirect
52+
golang.org/x/net v0.17.0 // indirect
53+
golang.org/x/sys v0.14.0 // indirect
54+
golang.org/x/time v0.4.0 // indirect
55+
golang.org/x/tools v0.14.0 // indirect
56+
google.golang.org/appengine v1.6.8 // indirect
5757
google.golang.org/protobuf v1.31.0 // indirect
5858
gopkg.in/warnings.v0 v0.1.2 // indirect
5959
)

go.sum

Lines changed: 55 additions & 163 deletions
Large diffs are not rendered by default.

internal/app/awesome-ci/scm-portal/github/issues.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/fullstack-devops/awesome-ci/internal/pkg/semver"
99
log "github.com/sirupsen/logrus"
1010

11-
"github.com/google/go-github/v53/github"
11+
"github.com/google/go-github/v56/github"
1212
)
1313

1414
var (
@@ -90,7 +90,8 @@ func (ghrc *GitHubRichClient) CommentHelpToPullRequest(number int) (err error) {
9090
return
9191
}
9292

93-
func (ghrc *GitHubRichClient) SearchIssuesForOverrides(prNumber int) (nextVersion string, patchLevel semver.PatchLevel, err error) {
93+
func (ghrc *GitHubRichClient) SearchIssuesForOverrides(prNumber int) (nextVersion *string, patchLevel *semver.PatchLevel, err error) {
94+
var pLevel semver.PatchLevel
9495
// if an comment exists with aci_patch_level=major, make a major version!
9596
issueComments, err := ghrc.GetIssueComments(prNumber)
9697
if err != nil {
@@ -115,17 +116,18 @@ func (ghrc *GitHubRichClient) SearchIssuesForOverrides(prNumber int) (nextVersio
115116
aciPatchLevel := regexp.MustCompile(`^aci_patch_level: ([a-zA-Z]+)`)
116117

117118
if aciVersionOverride.MatchString(*comment.Body) {
118-
nextVersion = aciVersionOverride.FindStringSubmatch(*comment.Body)[1]
119+
nextVersion = &aciVersionOverride.FindStringSubmatch(*comment.Body)[1]
119120
log.Infof("found version override in comment form %s at %s", comment.User.GetLogin(), comment.GetCreatedAt())
120121
break
121122
}
122123

123124
if aciPatchLevel.MatchString(*comment.Body) {
124-
patchLevel, err = semver.ParsePatchLevel(aciPatchLevel.FindStringSubmatch(*comment.Body)[1])
125+
pLevel, err = semver.ParsePatchLevel(aciPatchLevel.FindStringSubmatch(*comment.Body)[1])
125126
if err != nil && err != semver.ErrUseMinimalPatchVersion {
126127
log.Warnln(err)
127128
}
128129
log.Infof("found patchLevel override in comment form %s at %s", comment.User.GetLogin(), comment.GetCreatedAt())
130+
patchLevel = &pLevel
129131
break
130132
}
131133
}

internal/app/awesome-ci/scm-portal/github/models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package github
22

3-
import "github.com/google/go-github/v53/github"
3+
import "github.com/google/go-github/v56/github"
44

55
type GitHubRichClient struct {
66
Client *github.Client

internal/app/awesome-ci/scm-portal/github/pullrequest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package github
33
import (
44
"fmt"
55

6-
"github.com/google/go-github/v53/github"
6+
"github.com/google/go-github/v56/github"
77
log "github.com/sirupsen/logrus"
88
)
99

internal/app/awesome-ci/scm-portal/github/release.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/fullstack-devops/awesome-ci/internal/pkg/tools"
99

1010
"github.com/go-git/go-git/v5"
11-
"github.com/google/go-github/v53/github"
11+
"github.com/google/go-github/v56/github"
1212
log "github.com/sirupsen/logrus"
1313
)
1414

@@ -129,7 +129,7 @@ func (ghrc *GitHubRichClient) GetLatestReleaseVersion() (latestRelease *github.R
129129
Page: page,
130130
})
131131
if err != nil {
132-
log.Fatalf("error at loading repos from emst: %v", err)
132+
log.Fatalf("error at loading repos from: %v", err)
133133
}
134134

135135
log.Tracef("found %d releases at page %d begin with mapping...", len(releases), page)

internal/app/awesome-ci/scm-portal/github/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"github.com/fullstack-devops/awesome-ci/internal/pkg/tools"
99

10-
"github.com/google/go-github/v53/github"
10+
"github.com/google/go-github/v56/github"
1111
log "github.com/sirupsen/logrus"
1212
"golang.org/x/oauth2"
1313
)

internal/app/awesome-ci/scm-portal/issues.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ import (
99
)
1010

1111
func (lay SCMLayer) SearchIssuesForOverrides(number int) (nextVersion *string, patchLevel *semver.PatchLevel, err error) {
12-
var nVersion string
13-
var pLevel semver.PatchLevel
1412

1513
switch grc := lay.Grc.(type) {
1614

1715
case *github.GitHubRichClient:
18-
nVersion, pLevel, err = grc.SearchIssuesForOverrides(number)
16+
nextVersion, patchLevel, err = grc.SearchIssuesForOverrides(number)
1917
if err != nil {
2018
return nil, nil, err
2119
}
@@ -25,16 +23,5 @@ func (lay SCMLayer) SearchIssuesForOverrides(number int) (nextVersion *string, p
2523
log.Warnln("gitlab is not yet implemented")
2624
}
2725

28-
if nVersion == "" {
29-
nextVersion = nil
30-
} else {
31-
nextVersion = &nVersion
32-
}
33-
if pLevel == "" {
34-
patchLevel = nil
35-
} else {
36-
patchLevel = &pLevel
37-
}
38-
3926
return
4027
}

internal/app/awesome-ci/scm-portal/prmr_request.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,18 @@ func (lay SCMLayer) GetPrInfos(number int, mergeCommitSha string) (infos *PrMrRe
5858
}
5959
log.Tracef("read comments from pr/mr complete conclusions (if nil no override), version: %v, patchLevel: %v", version, patchLevel)
6060

61-
// get latest release, if any
62-
log.Traceln("get latest release, if any")
63-
repositoryRelease, err := lay.GetLatestReleaseVersion()
64-
if err != nil {
65-
log.Infoln("no github release found -> wirting default 0.0.0")
66-
infos.LatestVersion = "0.0.0"
67-
} else {
68-
log.Infoln("found latest release", repositoryRelease.TagName)
69-
infos.LatestVersion = repositoryRelease.TagName
70-
}
71-
7261
// check if version override (3)
7362
if version == nil {
63+
// get latest release, if any
64+
log.Traceln("get latest release, if any")
65+
repositoryRelease, err := lay.GetLatestReleaseVersion()
66+
if err != nil {
67+
log.Infoln("no github release found -> writing default 0.0.0")
68+
infos.LatestVersion = "0.0.0"
69+
} else {
70+
log.Infoln("found latest release", repositoryRelease.TagName)
71+
infos.LatestVersion = repositoryRelease.TagName
72+
}
7473

7574
if patchLevel != nil {
7675
infos.PatchLevel = *patchLevel

internal/app/awesome-ci/service_test/helper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/go-git/go-git/v5"
1818
"github.com/go-git/go-git/v5/plumbing"
1919
"github.com/go-git/go-git/v5/plumbing/transport/http"
20-
"github.com/google/go-github/v53/github"
20+
"github.com/google/go-github/v56/github"
2121
)
2222

2323
type TestEnvironment struct {

0 commit comments

Comments
 (0)