Skip to content

Commit

Permalink
fix bug once and for all
Browse files Browse the repository at this point in the history
  • Loading branch information
verdverm committed May 31, 2020
1 parent 9aac181 commit 3eee814
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
11 changes: 6 additions & 5 deletions lib/mod/cache/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func fetchGitHub(lang, owner, repo, tag string) (err error) {
return fmt.Errorf("While fetching from github\n%w\n", err)
}

/*
fmt.Println("filelist:")
files, err := yagu.BillyGetFilelist(FS)
if err != nil {
Expand All @@ -76,6 +77,7 @@ func fetchGitHub(lang, owner, repo, tag string) (err error) {
}
fmt.Println("Writing...", )
*/
err = Write(lang, "github.com", owner, repo, tag, FS)
if err != nil {
return fmt.Errorf("While writing to cache\n%w\n", err)
Expand All @@ -100,7 +102,7 @@ func fetchGitHubBranch(FS billy.Filesystem, lang, owner, repo, branch string) er
fmt.Printf("%#+v\n", *r)
}

fmt.Println("Fetch github branch", lang, owner, repo, branch)
// fmt.Println("Fetch github BRANCH", lang, owner, repo, branch)

zReader, err := github.FetchBranchZip(client, branch)
if err != nil {
Expand All @@ -115,7 +117,7 @@ func fetchGitHubBranch(FS billy.Filesystem, lang, owner, repo, branch string) er
return nil
}
func fetchGitHubTag(FS billy.Filesystem, lang, owner, repo, tag string) error {
fmt.Println("Fetch github tag", lang, owner, repo, tag)
// fmt.Println("Fetch github TAG", lang, owner, repo, tag)
client, err := github.NewClient()
if err != nil {
return err
Expand All @@ -131,14 +133,13 @@ func fetchGitHubTag(FS billy.Filesystem, lang, owner, repo, tag string) error {
for _, t := range tags {
if tag != "" && tag == *t.Name {
T = t
fmt.Printf("FOUND %v\n", *t)
// fmt.Printf("FOUND %v\n", *t.Name)
}
// fmt.Println(*t.Name, *t.Commit.SHA)
}

if T == nil {
return fmt.Errorf("Did not find tag %q for 'https://github.com/%s/%s' @%s", tag, owner, repo, tag)
}

zReader, err := github.FetchTagZip(client, T)
if err != nil {
return fmt.Errorf("While fetching tag zipfile\n%w\n", err)
Expand Down
4 changes: 4 additions & 0 deletions lib/mod/cli_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mod_test

import (
"os"
"testing"

"github.com/rogpeppe/go-internal/testscript"
Expand All @@ -9,6 +10,9 @@ import (
)

func envSetup(env *testscript.Env) error {
if token := os.Getenv("GITHUB_TOKEN"); token != "" {
env.Vars = append(env.Vars, "GITHUB_TOKEN="+token)
}
env.Vars = append(env.Vars, "HOF_TELEMETRY_DISABLED=1")
return nil
}
Expand Down
Empty file removed lib/mod/testdata/bugs/.gitkeep
Empty file.
17 changes: 17 additions & 0 deletions lib/mod/testdata/bugs/keep_me.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# hof mod vendor - keep me so go test does not complaing
exec hof mod vendor

-- cue.mods --
module github.com/test/withsolo

cue v0.2.0

require (
github.com/hofstadter-io/hof v0.5.4
)
-- cue.mod/module.cue --
module: "github.com/test/withsolo"
-- dummy_end --



20 changes: 4 additions & 16 deletions lib/yagu/repos/github/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,22 @@ func GetTagsSplit(client *github.Client, module string) ([]*github.RepositoryTag

func GetRepo(client *github.Client, owner, repo string) (*github.Repository, error) {
r, _, err := client.Repositories.Get(context.Background(), owner, repo)
if err != nil {
return nil, err
}
return r, nil
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)
if err != nil {
return nil, err
}
return b, nil
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)
if err != nil {
return nil, err
}
return bs, 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)
if err != nil {
return nil, err
}
return tags, nil
return tags, err
}

func FetchTagZip(client *github.Client, tag *github.RepositoryTag) (*zip.Reader, error) {
Expand Down

0 comments on commit 3eee814

Please sign in to comment.