Skip to content

Commit

Permalink
Merge branch 'main' into refactor-return-db-schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper authored Aug 8, 2023
2 parents c9595b4 + b3084f9 commit e017832
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 e017832

Please sign in to comment.