Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle azure devops url #1463

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,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.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZtmFVPHmA=
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
Loading