-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add package wd_info_parse and wd_info.RepositoryInfo parse from…
… CI_REPO_CLONE_URL wd_info.RepositoryInfo member CiRepoHost CiRepoHostname CiRepoPort form env CI_REPO_CLONE_URL
- Loading branch information
Showing
11 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package wd_info_parse | ||
|
||
import ( | ||
"fmt" | ||
gitUrls "github.com/chainguard-dev/git-urls" | ||
"github.com/woodpecker-kit/woodpecker-tools/wd_info" | ||
"strings" | ||
) | ||
|
||
func ParseRepositoryInfoByWoodPeckerInfo(info *wd_info.WoodpeckerInfo) error { | ||
|
||
if info.RepositoryInfo.CIRepoCloneURL == "" { | ||
return fmt.Errorf("RepositoryInfo.CIRepoCloneURL is empty") | ||
} | ||
|
||
parse, errParse := gitUrls.Parse(info.RepositoryInfo.CIRepoCloneURL) | ||
if errParse != nil { | ||
return fmt.Errorf("RepositoryInfo.CIRepoCloneURL parse err: %s", errParse) | ||
} | ||
if strings.Contains(parse.Scheme, "http") { | ||
info.RepositoryInfo.CiRepoHost = parse.Host | ||
info.RepositoryInfo.CiRepoHostname = parse.Hostname() | ||
info.RepositoryInfo.CiRepoPort = parse.Port() | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func ParseRepositoryInfoByRepositoryInfo(info *wd_info.RepositoryInfo) error { | ||
|
||
if info.CIRepoCloneURL == "" { | ||
return fmt.Errorf("RepositoryInfo.CIRepoCloneURL is empty") | ||
} | ||
|
||
parse, errParse := gitUrls.Parse(info.CIRepoCloneURL) | ||
if errParse != nil { | ||
return fmt.Errorf("RepositoryInfo.CIRepoCloneURL parse err: %s", errParse) | ||
} | ||
if strings.Contains(parse.Scheme, "http") { | ||
info.CiRepoHost = parse.Host | ||
info.CiRepoHostname = parse.Hostname() | ||
info.CiRepoPort = parse.Port() | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters