From 8b81007ef19271385014a170be6a57973ab674f0 Mon Sep 17 00:00:00 2001 From: AkashRajpurohit Date: Thu, 1 Aug 2024 11:54:15 +0530 Subject: [PATCH] feat: :sparkles: fork checking added for gitlab --- pkg/gitlab/gitlab.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/gitlab/gitlab.go b/pkg/gitlab/gitlab.go index 4cd3790..81955c4 100644 --- a/pkg/gitlab/gitlab.go +++ b/pkg/gitlab/gitlab.go @@ -60,11 +60,12 @@ func (c GitlabClient) GetProjects(cfg config.Config) ([]*gl.Project, error) { var projectsToInclude []*gl.Project for _, project := range projects { projectName := project.Path - IsGroupProject := project.Namespace.Kind == "group" + isFork := project.ForkedFromProject != nil + isGroupProject := project.Namespace.Kind == "group" groupName := project.Namespace.FullPath if len(cfg.IncludeOrgs) > 0 { - if IsGroupProject && helpers.IsIncludedInList(cfg.IncludeOrgs, groupName) { + if isGroupProject && helpers.IsIncludedInList(cfg.IncludeOrgs, groupName) { logger.Debug("[include_groups] Project included: ", projectName) projectsToInclude = append(projectsToInclude, project) } @@ -74,7 +75,7 @@ func (c GitlabClient) GetProjects(cfg config.Config) ([]*gl.Project, error) { // If exclude orgs are set, exclude those and move to next checks if any if len(cfg.ExcludeOrgs) > 0 { - if IsGroupProject && helpers.IsExcludedInList(cfg.ExcludeOrgs, groupName) { + if isGroupProject && helpers.IsExcludedInList(cfg.ExcludeOrgs, groupName) { logger.Debug("[exclude_groups] Project excluded: ", projectName) continue } @@ -96,6 +97,11 @@ func (c GitlabClient) GetProjects(cfg config.Config) ([]*gl.Project, error) { } } + if !cfg.IncludeForks && isFork { + logger.Debug("[include_forks] Fork excluded: ", projectName) + continue + } + logger.Debug("Project included: ", projectName) projectsToInclude = append(projectsToInclude, project) }