mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-29 21:31:02 +00:00
update listing
This commit is contained in:
parent
cf549e47c3
commit
7826888729
6 changed files with 18 additions and 13 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue