From ba172461f403d3b7a48e7f34f99e1385b8505d7c Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 18 Dec 2020 13:59:16 -0500 Subject: [PATCH] support for gitlab and github internal visibility --- CHANGELOG.md | 1 + go.mod | 2 +- go.sum | 2 ++ service/repo/util.go | 6 ++++++ service/repo/util_test.go | 4 ++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0f5b3e8..a059f195 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] ### Added - support for repository-level concurrency limits. +- support for gitlab and github internal visibility on initial sync. ## [1.10.0] ### Added diff --git a/go.mod b/go.mod index 5cbaa771..dab9dd60 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629 github.com/drone/go-license v1.0.2 github.com/drone/go-login v1.0.4-0.20190311170324-2a4df4f242a2 - github.com/drone/go-scm v1.7.2-0.20201111225713-c0438b46084b + github.com/drone/go-scm v1.8.0 github.com/drone/signal v1.0.0 github.com/dustin/go-humanize v1.0.0 github.com/go-chi/chi v3.3.3+incompatible diff --git a/go.sum b/go.sum index 824d77d5..f57e0afe 100644 --- a/go.sum +++ b/go.sum @@ -106,6 +106,8 @@ github.com/drone/go-scm v1.7.2-0.20201028160627-427b8a85897c h1:3Dv6guONE4nry6fv github.com/drone/go-scm v1.7.2-0.20201028160627-427b8a85897c/go.mod h1:lXwfbyrIJwFFME5TpzavkwO2T5X8yBK6t6cve7g91x0= github.com/drone/go-scm v1.7.2-0.20201111225713-c0438b46084b h1:ivLeFPmHN+9sLMVAF7HvgvEglU5tzoqlzePLY5zKPo8= github.com/drone/go-scm v1.7.2-0.20201111225713-c0438b46084b/go.mod h1:lXwfbyrIJwFFME5TpzavkwO2T5X8yBK6t6cve7g91x0= +github.com/drone/go-scm v1.8.0 h1:kDHu38a11loKf6uaBu75TmY1YPwsSaZdseET738Oy0o= +github.com/drone/go-scm v1.8.0/go.mod h1:lXwfbyrIJwFFME5TpzavkwO2T5X8yBK6t6cve7g91x0= github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI= github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= diff --git a/service/repo/util.go b/service/repo/util.go index 3a2d6333..ef917325 100644 --- a/service/repo/util.go +++ b/service/repo/util.go @@ -41,6 +41,12 @@ func convertRepository(src *scm.Repository, visibility string, trusted bool) *co // convertVisibility is a helper function that returns the // repository visibility based on the privacy flag. func convertVisibility(src *scm.Repository, visibility string) string { + // if the visibility is set to internal (github enterprise and gitlab) + // and the global visibility is empty, automatically set to internal. + if visibility == "" && src.Visibility == scm.VisibilityInternal { + return core.VisibilityInternal + } + switch { case src.Private == true: return core.VisibilityPrivate diff --git a/service/repo/util_test.go b/service/repo/util_test.go index 84cadd05..d4cfd66c 100644 --- a/service/repo/util_test.go +++ b/service/repo/util_test.go @@ -55,6 +55,10 @@ func TestConvertVisibility(t *testing.T) { r: &scm.Repository{Private: true}, v: core.VisibilityPrivate, }, + { + r: &scm.Repository{Private: true, Visibility: scm.VisibilityInternal}, + v: core.VisibilityInternal, + }, } for i, test := range tests {