Skip to content

Commit

Permalink
fix: handle azure devops url (#1463)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfabianski committed Jan 12, 2024
1 parent 49c6944 commit a5d27c9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,5 @@ require (
)

replace github.com/spf13/viper => github.com/cfabianski/viper v1.15.1-0.20231221085120-53a0f7864cd6

replace github.com/gitsight/go-vcsurl => github.com/bearer/go-vcsurl v0.0.0-20240112143255-3be11ce9a61e
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/bearer/go-vcsurl v0.0.0-20240112143255-3be11ce9a61e h1:JdIgUziiF2hbiWVYspGis73t/8hXx39bsgQtE6xpFyk=
github.com/bearer/go-vcsurl v0.0.0-20240112143255-3be11ce9a61e/go.mod h1:qRFdKDa/0Lh9MT0xE+qQBYZ/01+mY1H40rZUHR24X9U=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
Expand Down Expand Up @@ -67,8 +69,6 @@ github.com/gertd/go-pluralize v0.2.1 h1:M3uASbVjMnTsPb0PNqg+E/24Vwigyo/tvyMTtAlL
github.com/gertd/go-pluralize v0.2.1/go.mod h1:rbYaKDbsXxmRfr8uygAEKhOWsjyrrqrkHVpZvoOp8zk=
github.com/gitleaks/go-gitdiff v0.9.0 h1:SHAU2l0ZBEo8g82EeFewhVy81sb7JCxW76oSPtR/Nqg=
github.com/gitleaks/go-gitdiff v0.9.0/go.mod h1:pKz0X4YzCKZs30BL+weqBIG7mx0jl4tF1uXV9ZyNvrA=
github.com/gitsight/go-vcsurl v1.0.1 h1:wkijKsbVg9R2IBP97U7wOANeIW9WJJKkBwS9XqllzWo=
github.com/gitsight/go-vcsurl v1.0.1/go.mod h1:qRFdKDa/0Lh9MT0xE+qQBYZ/01+mY1H40rZUHR24X9U=
github.com/go-enry/go-enry/v2 v2.8.4 h1:QrY3hx/RiqCJJRbdU0MOcjfTM1a586J0WSooqdlJIhs=
github.com/go-enry/go-enry/v2 v2.8.4/go.mod h1:9yrj4ES1YrbNb1Wb7/PWYr2bpaCXUGRt0uafN0ISyG8=
github.com/go-enry/go-oniguruma v1.2.1 h1:k8aAMuJfMrqm/56SG2lV9Cfti6tC4x8673aHCcBk+eo=
Expand Down
40 changes: 28 additions & 12 deletions internal/commands/process/gitrepository/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,9 @@ func NewContext(options *flagtypes.Options) (*Context, error) {
return nil, fmt.Errorf("error getting origin url: %w", err)
}

var id, host, owner, name, fullName string
if originURL != "" {
urlInfo, err := vcsurl.Parse(originURL)
if err != nil {
return nil, fmt.Errorf("couldn't parse origin url: %w", err)
}

id = urlInfo.ID
host = string(urlInfo.Host)
owner = urlInfo.Username
name = urlInfo.Name
fullName = urlInfo.FullName
id, host, owner, name, fullName, err := getSCMInfo(originURL)
if err != nil {
return nil, err
}

context := &Context{
Expand All @@ -118,6 +109,31 @@ func NewContext(options *flagtypes.Options) (*Context, error) {
return context, nil
}

func getSCMInfo(originURL string) (
id,
host,
owner,
name,
fullName string,
scmParseError error,
) {
if originURL != "" {
urlInfo, err := vcsurl.Parse(originURL)
if err != nil {
scmParseError = fmt.Errorf("couldn't parse origin url: %s", originURL)
return
}

id = urlInfo.ID
host = string(urlInfo.Host)
owner = urlInfo.Username
name = urlInfo.Name
fullName = urlInfo.FullName
}

return
}

func getBranch(options *flagtypes.Options, currentBranch string) string {
if options.Branch != "" {
return options.Branch
Expand Down

0 comments on commit a5d27c9

Please sign in to comment.