Skip to content

Commit

Permalink
feat: ✨ fork checking added for gitlab
Browse files Browse the repository at this point in the history
  • Loading branch information
AkashRajpurohit committed Aug 1, 2024
1 parent a65dc82 commit 8b81007
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
}
Expand All @@ -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)
}
Expand Down

0 comments on commit 8b81007

Please sign in to comment.