update listing

This commit is contained in:
Brad Rydzewski 2017-08-26 15:59:57 -07:00
parent cf549e47c3
commit 7826888729
6 changed files with 18 additions and 13 deletions

View file

@ -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
}

View file

@ -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",
}

View file

@ -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")

View file

@ -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
}

View file

@ -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",
}

View file

@ -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")