diff --git a/remote/gitea/gitea.go b/remote/gitea/gitea.go index af2c56852..e9d1fa2d2 100644 --- a/remote/gitea/gitea.go +++ b/remote/gitea/gitea.go @@ -195,7 +195,7 @@ func (c *client) Repo(u *model.User, owner, name string) (*model.Repo, error) { if c.PrivateMode { repo.Private = true } - return toRepo(repo), nil + return toRepo(repo, c.PrivateMode), nil } // Repos returns a list of all repositories for the Gitea account, including @@ -210,7 +210,7 @@ func (c *client) Repos(u *model.User) ([]*model.Repo, error) { } for _, repo := range all { - repos = append(repos, toRepo(repo)) + repos = append(repos, toRepo(repo, c.PrivateMode)) } return repos, err } diff --git a/remote/gitea/helper.go b/remote/gitea/helper.go index ead57c052..d625dc040 100644 --- a/remote/gitea/helper.go +++ b/remote/gitea/helper.go @@ -13,12 +13,16 @@ import ( ) // helper function that converts a Gitea repository to a Drone repository. -func toRepo(from *gitea.Repository) *model.Repo { +func toRepo(from *gitea.Repository, privateMode bool) *model.Repo { name := strings.Split(from.FullName, "/")[1] avatar := expandAvatar( from.HTMLURL, from.Owner.AvatarURL, ) + private := from.Private + if privateMode { + private = true + } return &model.Repo{ Kind: model.RepoGit, Name: name, @@ -26,7 +30,7 @@ func toRepo(from *gitea.Repository) *model.Repo { FullName: from.FullName, Avatar: avatar, Link: from.HTMLURL, - IsPrivate: from.Private, + IsPrivate: private, Clone: from.CloneURL, Branch: "master", } diff --git a/remote/gitea/helper_test.go b/remote/gitea/helper_test.go index ca01ffe45..4bdcdc41b 100644 --- a/remote/gitea/helper_test.go +++ b/remote/gitea/helper_test.go @@ -166,7 +166,7 @@ func Test_parse(t *testing.T) { HTMLURL: "http://gitea.golang.org/gophers/hello-world", Private: true, } - repo := toRepo(&from) + repo := toRepo(&from, false) g.Assert(repo.FullName).Equal(from.FullName) g.Assert(repo.Owner).Equal(from.Owner.UserName) g.Assert(repo.Name).Equal("hello-world") diff --git a/remote/gogs/gogs.go b/remote/gogs/gogs.go index d3de92d08..97dcf45a6 100644 --- a/remote/gogs/gogs.go +++ b/remote/gogs/gogs.go @@ -134,10 +134,7 @@ func (c *client) Repo(u *model.User, owner, name string) (*model.Repo, error) { if err != nil { return nil, err } - if c.PrivateMode { - repo.Private = true - } - return toRepo(repo), nil + return toRepo(repo, c.PrivateMode), nil } // Repos returns a list of all repositories for the Gogs account, including @@ -152,7 +149,7 @@ func (c *client) Repos(u *model.User) ([]*model.Repo, error) { } for _, repo := range all { - repos = append(repos, toRepo(repo)) + repos = append(repos, toRepo(repo, c.PrivateMode)) } return repos, err } diff --git a/remote/gogs/helper.go b/remote/gogs/helper.go index ff62abcfd..8b9420ed7 100644 --- a/remote/gogs/helper.go +++ b/remote/gogs/helper.go @@ -13,12 +13,16 @@ import ( ) // helper function that converts a Gogs repository to a Drone repository. -func toRepo(from *gogs.Repository) *model.Repo { +func toRepo(from *gogs.Repository, privateMode bool) *model.Repo { name := strings.Split(from.FullName, "/")[1] avatar := expandAvatar( from.HtmlUrl, from.Owner.AvatarUrl, ) + private := from.Private + if privateMode { + private = true + } return &model.Repo{ Kind: model.RepoGit, Name: name, @@ -26,7 +30,7 @@ func toRepo(from *gogs.Repository) *model.Repo { FullName: from.FullName, Avatar: avatar, Link: from.HtmlUrl, - IsPrivate: from.Private, + IsPrivate: private, Clone: from.CloneUrl, Branch: "master", } diff --git a/remote/gogs/helper_test.go b/remote/gogs/helper_test.go index 4af534bb4..41ec32eba 100644 --- a/remote/gogs/helper_test.go +++ b/remote/gogs/helper_test.go @@ -165,7 +165,7 @@ func Test_parse(t *testing.T) { HtmlUrl: "http://gogs.golang.org/gophers/hello-world", Private: true, } - repo := toRepo(&from) + repo := toRepo(&from, false) g.Assert(repo.FullName).Equal(from.FullName) g.Assert(repo.Owner).Equal(from.Owner.UserName) g.Assert(repo.Name).Equal("hello-world")