-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
push mod fetch details into remote types
Signed-off-by: Tony Worm <tony@hofstadter.io>
- Loading branch information
Showing
6 changed files
with
137 additions
and
162 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
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,47 @@ | ||
package github | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/google/go-github/v30/github" | ||
) | ||
|
||
func GetTagsSplit(client *github.Client, module string) ([]*github.RepositoryTag, error) { | ||
flds := strings.SplitN(module, "/", 1) | ||
domain, rest := flds[0], flds[1] | ||
|
||
if domain != "github.com" { | ||
return nil, fmt.Errorf("Github Tags Fetch called with non 'github.com' domain %q", module) | ||
} | ||
|
||
flds = strings.Split(rest, "/") | ||
owner, repo := flds[0], flds[1] | ||
tags, _, err := client.Repositories.ListTags(context.Background(), owner, repo, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return tags, nil | ||
} | ||
|
||
func GetRepo(client *github.Client, owner, repo string) (*github.Repository, error) { | ||
r, _, err := client.Repositories.Get(context.Background(), owner, repo) | ||
return r, err | ||
} | ||
|
||
func GetBranch(client *github.Client, owner, repo, branch string) (*github.Branch, error) { | ||
b, _, err := client.Repositories.GetBranch(context.Background(), owner, repo, branch) | ||
return b, err | ||
} | ||
|
||
func GetBranches(client *github.Client, owner, repo, branch string) ([]*github.Branch, error) { | ||
bs, _, err := client.Repositories.ListBranches(context.Background(), owner, repo, nil) | ||
return bs, err | ||
} | ||
|
||
func GetTags(client *github.Client, owner, repo string) ([]*github.RepositoryTag, error) { | ||
tags, _, err := client.Repositories.ListTags(context.Background(), owner, repo, nil) | ||
return tags, err | ||
} | ||
|
Oops, something went wrong.