Skip to content

Commit

Permalink
fix: guess major version.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jul 16, 2021
1 parent a70448f commit 4aa5c50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ func guessVersion(lib string, latest bool, rawVersion string) (string, string, e
}

func findHighestFromGoPkg(lib string) (string, error) {
licenseURL := fmt.Sprintf("https://pkg.go.dev/%s?tab=licenses", lib)
fmt.Println("findHighestFromGoPkg")
licenseURL := fmt.Sprintf("https://pkg.go.dev/%s", lib)

req, err := http.NewRequest(http.MethodGet, licenseURL, nil)
if err != nil {
Expand All @@ -187,7 +188,7 @@ func findHighestFromGoPkg(lib string) (string, error) {
return "", err
}

compile := cascadia.MustCompile("div.UnitHeader-banner.UnitHeader-banner--majorVersion span a")
compile := cascadia.MustCompile("div.go-Main-banner div.go-Message.go-Message--notice a")

node := cascadia.Query(doc, compile)
if node != nil && node.FirstChild != nil {
Expand Down
6 changes: 3 additions & 3 deletions upgrader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func Test_guessVersion(t *testing.T) {
baseModuleName: "github.com/google/go-github",
raw: "latest",
expected: expected{
Major: "v34",
Full: "v34.0.0",
Major: "v37",
Full: "v37.0.0",
},
},
{
Expand All @@ -149,7 +149,7 @@ func Test_guessVersion(t *testing.T) {
raw: "latest",
expected: expected{
Major: "v4",
Full: "v4.1.0",
Full: "v4.1.1",
},
},
}
Expand Down

0 comments on commit 4aa5c50

Please sign in to comment.