Skip to content

Commit

Permalink
fix: getting visbility to match on vela and SCM (#924)
Browse files Browse the repository at this point in the history
* enhance: getting visbility to match on vela and SCM

* fix: modifying test cases to consider new visibility changes

---------

Co-authored-by: Claire.Nicholas <Z00B3R3@w6nxmk4t6t.target.com>
  • Loading branch information
claire1618 and Claire.Nicholas committed Aug 4, 2023
1 parent adf4f65 commit b3084f9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
6 changes: 2 additions & 4 deletions api/repo/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,8 @@ func CreateRepo(c *gin.Context) {
}

// set the visibility field based off the input provided
if len(input.GetVisibility()) == 0 {
// default visibility field to public
r.SetVisibility(constants.VisibilityPublic)
} else {
if len(input.GetVisibility()) > 0 {
// default visibility field to the input visibility
r.SetVisibility(input.GetVisibility())
}

Expand Down
25 changes: 17 additions & 8 deletions scm/github/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,24 @@ func (c *client) ListUserRepos(u *library.User) ([]*library.Repo, error) {

// toLibraryRepo does a partial conversion of a github repo to a library repo.
func toLibraryRepo(gr github.Repository) *library.Repo {
// setting the visbility to match the SCM visbility
var visibility string
if *gr.Private {
visibility = constants.VisibilityPrivate
} else {
visibility = constants.VisibilityPublic
}

return &library.Repo{
Org: gr.GetOwner().Login,
Name: gr.Name,
FullName: gr.FullName,
Link: gr.HTMLURL,
Clone: gr.CloneURL,
Branch: gr.DefaultBranch,
Topics: &gr.Topics,
Private: gr.Private,
Org: gr.GetOwner().Login,
Name: gr.Name,
FullName: gr.FullName,
Link: gr.HTMLURL,
Clone: gr.CloneURL,
Branch: gr.DefaultBranch,
Topics: &gr.Topics,
Private: gr.Private,
Visibility: &visibility,
}
}

Expand Down
2 changes: 2 additions & 0 deletions scm/github/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ func TestGithub_GetRepo(t *testing.T) {
want.SetBranch("master")
want.SetPrivate(false)
want.SetTopics([]string{"octocat", "atom", "electron", "api"})
want.SetVisibility("public")

client, _ := NewTest(s.URL)

Expand Down Expand Up @@ -1191,6 +1192,7 @@ func TestGithub_ListUserRepos(t *testing.T) {
r.SetBranch("master")
r.SetPrivate(false)
r.SetTopics([]string{"octocat", "atom", "electron", "api"})
r.SetVisibility("public")

want := []*library.Repo{r}

Expand Down

0 comments on commit b3084f9

Please sign in to comment.