Skip to content

Commit

Permalink
fix github url issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jajita committed Oct 3, 2024
1 parent dfdd163 commit 5597bf8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 0 additions & 4 deletions internal/commands/release_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
"text/template"
"time"

Expand Down Expand Up @@ -282,9 +281,6 @@ func getGithubRemoteRepoOwnerAndName(repo *git.Repository) (string, string, erro
}
config := remote.Config()
for _, u := range config.URLs {
if !strings.Contains(u, "github.com") {
continue
}
remoteURL = u
break
}
Expand Down
9 changes: 8 additions & 1 deletion internal/gh/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/url"
"path/filepath"
"regexp"
"strings"
)

Expand All @@ -13,7 +14,13 @@ func RepositoryOwnerAndNameFromPath(urlStr string) (owner, repo string, err erro
wrapError := func(urlStr string, err error) error {
return fmt.Errorf("failed to parse owner and repo name from URI %q: %w", urlStr, err)
}
urlStr = strings.TrimPrefix(urlStr, "git@github.com:")

sshReg := regexp.MustCompile(`(?m)git@(?P<host>.*):(?P<owner>[^/]+)/(?P<name>.*)\.git`)
if m := sshReg.FindStringSubmatch(urlStr); m != nil {
owner = m[sshReg.SubexpIndex("owner")]
repo = m[sshReg.SubexpIndex("name")]
return owner, repo, nil
}
u, err := url.Parse(urlStr)
if err != nil {
return "", "", wrapError(urlStr, err)
Expand Down
6 changes: 5 additions & 1 deletion pkg/cargo/bump.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cargo
import (
"context"
"fmt"
"log"
"slices"
"sort"
"strings"
Expand Down Expand Up @@ -208,7 +209,10 @@ func fetchReleasesFromRepo(ctx context.Context, repoService RepositoryReleaseLis
var result []*github.RepositoryRelease

ops := github.ListOptions{}
releases, _, _ := repoService.ListReleases(ctx, owner, repo, &ops)
releases, _, err := repoService.ListReleases(ctx, owner, repo, &ops)
if err != nil {
log.Println(err)
}

for _, rel := range releases {
rv, err := semver.NewVersion(strings.TrimPrefix(rel.GetTagName(), "v"))
Expand Down

0 comments on commit 5597bf8

Please sign in to comment.