Skip to content

Commit

Permalink
Do not delete groups if they still contain any projects or subgroups.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adambean committed Jan 25, 2019
1 parent fe2ed2c commit b2979db
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/LdapSyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,16 @@ private function deployGitlabUsersAndGroups(array $config, string $gitlabInstanc
continue;
}

if (is_array($gitlabGroupProjects = $gitlab->api("groups")->projects($gitlabGroupId)) && ($gitlabGroupProjectsNum = count($gitlabGroupProjects)) >= 1) {
$this->logger->info(sprintf("Not deleting Gitlab group #%d \"%s\" [%s]: It contains %d project(s).", $gitlabGroupId, $gitlabGroupName, $gitlabGroupPath, $gitlabGroupProjectsNum));
continue;
}

if (is_array($gitlabGroupSubGroups = $gitlab->api("groups")->subgroups($gitlabGroupId)) && ($gitlabGroupSubGroupsNum = count($gitlabGroupSubGroups)) >= 1) {
$this->logger->info(sprintf("Not deleting Gitlab group #%d \"%s\" [%s]: It contains %d subgroup(s).", $gitlabGroupId, $gitlabGroupName, $gitlabGroupPath, $gitlabGroupSubGroupsNum));
continue;
}

$this->logger->warning(sprintf("Deleting Gitlab group #%d \"%s\" [%s].", $gitlabGroupId, $gitlabGroupName, $gitlabGroupPath));
$gitlabGroup = null;

Expand Down

0 comments on commit b2979db

Please sign in to comment.