Commit c5c09668 authored by Martin Lowe's avatar Martin Lowe 🇨🇦
Browse files

Merge branch 'malowe/master/214' into 'master'

Iss #214 - Fix overzealous root group matching

See merge request !215
parents fb26fd22 8610fc65
Pipeline #5686 passed with stage
in 0 seconds
......@@ -364,6 +364,12 @@ export class GitlabSyncRunner {
*/
async cleanupProjects() {
this.projectsCache.forEach(async p => {
// don't process projects outside target namespace
if (!this.withinNamespace(p.namespace.full_path)) {
return;
}
// get the group of the project and clean it up
const group = await this.getCachedGroup(p.namespace.full_path);
if (group !== null) {
this.cleanUpProjectUsers(p, ...group!.projectTargets);
......@@ -658,7 +664,7 @@ export class GitlabSyncRunner {
if (this.config.verbose) {
this.logger.debug(`GitlabSync:getCachedGroup(${namespace})`);
}
if (!namespace.startsWith(this.config.rootGroup)) {
if (!this.withinNamespace(namespace)) {
this.logger.info(`Returning null for ${namespace} as it is outside of the root group ${this.config.rootGroup}`);
return null;
}
......@@ -816,4 +822,14 @@ export class GitlabSyncRunner {
isBot(uname: string, projectIDs: string[]): boolean {
return projectIDs.some(v => this.bots[v]?.indexOf(uname) !== -1);
}
/**
* Check to ensure that a given namespace is within the target group namespace.
*
* @param namespace the namespace to check
* @returns true if the namespace is under the configured root group, false otherwise.
*/
withinNamespace(namespace: string):boolean {
return namespace.startsWith(this.config.rootGroup + '/');
}
}
# Test cases
- Groups with a namespace root that starts with the target group aren't affected by cleanup. ([#214](https://gitlab.eclipse.org/eclipsefdn/it/webdev/eclipsefdn-vc-tools/-/issues/214))
- Check for this would be having eclipse and eclipsefdn as root groups, and to make sure that both groups and projects under the eclipsefdn root are unaffected by the cleanup. We should add users to both the group and project that aren't owners to test.
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment