From f82bad332bf0fadd10690a5e15adeeae71322a5e Mon Sep 17 00:00:00 2001 From: Nathaniel Wert Date: Wed, 21 Sep 2022 16:20:20 -0400 Subject: [PATCH] :sparkles: Gitlab support (#2265) * updated readme to reflect gitlab usage * bugfixes after a good deal of testing * removed unnecessary files from branch * cleaning up my mess * requested changes + unit tests * style fixes * updated readme to reflect gitlab usage * bugfixes after a good deal of testing * removed unnecessary files from branch * cleaning up my mess * requested changes + unit tests * style fixes * merge main into gitlab_support * check-linter fixes Signed-off-by: Nathaniel Wert Co-authored-by: nathaniel.wert Signed-off-by: N8BWert --- clients/gitlabrepo/branches.go | 8 ++++---- clients/gitlabrepo/client.go | 1 + clients/gitlabrepo/commits.go | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/clients/gitlabrepo/branches.go b/clients/gitlabrepo/branches.go index 724d395f8f73..5230a1f18fe6 100644 --- a/clients/gitlabrepo/branches.go +++ b/clients/gitlabrepo/branches.go @@ -43,6 +43,7 @@ func (handler *branchesHandler) init(repourl *repoURL) { handler.once = new(sync.Once) } +// nolint: nestif func (handler *branchesHandler) setup() error { handler.once.Do(func() { if !strings.EqualFold(handler.repourl.commitSHA, clients.HeadSHA) { @@ -225,10 +226,9 @@ func makeBranchRefFrom(branch *gitlab.Branch, protectedBranch *gitlab.ProtectedB projectApprovalRule *gitlab.ProjectApprovals, ) *clients.BranchRef { requiresStatusChecks := newFalse() - if projectStatusChecks != nil { - if len(projectStatusChecks) > 0 { - requiresStatusChecks = newTrue() - } + + if len(projectStatusChecks) > 0 { + requiresStatusChecks = newTrue() } statusChecksRule := clients.StatusChecksRule{ diff --git a/clients/gitlabrepo/client.go b/clients/gitlabrepo/client.go index 20f30afda1b6..ce38f5fa7cef 100644 --- a/clients/gitlabrepo/client.go +++ b/clients/gitlabrepo/client.go @@ -121,6 +121,7 @@ func (client *Client) InitRepo(inputRepo clients.Repo, commitSHA string) error { // Init tarballHandler. client.tarball.init(client.ctx, client.repourl, client.repo, commitSHA) + return nil } diff --git a/clients/gitlabrepo/commits.go b/clients/gitlabrepo/commits.go index a31ea8a5de77..796c003d5630 100644 --- a/clients/gitlabrepo/commits.go +++ b/clients/gitlabrepo/commits.go @@ -38,6 +38,7 @@ func (handler *commitsHandler) init(repourl *repoURL) { handler.once = new(sync.Once) } +// nolint: gocognit func (handler *commitsHandler) setup() error { handler.once.Do(func() { commits, _, err := handler.glClient.Commits.ListCommits(handler.repourl.projectID, &gitlab.ListCommitsOptions{})