mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 03:32:52 +00:00
@@ -13,14 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Api} from '@openstapps/gitlab-api';
|
||||
import {
|
||||
AccessLevel,
|
||||
IssueState,
|
||||
MembershipScope,
|
||||
Milestone,
|
||||
Project,
|
||||
Scope,
|
||||
} from '@openstapps/gitlab-api/lib/types';
|
||||
import {AccessLevel, IssueState, MembershipScope, Milestone, Project, Scope} from '@openstapps/gitlab-api/lib/types';
|
||||
import {asyncPool} from 'async-pool-native/dist/async-pool';
|
||||
import {flatten2dArray, getProjects, logger} from '../common';
|
||||
import {GROUPS, NEEDED_LABELS, NEEDED_MILESTONES, NOTE_PREFIX, PROTECTED_BRANCHES, SCHOOLS} from '../configuration';
|
||||
@@ -228,6 +221,40 @@ export async function tidyProtectedBranches(api: Api, projects: Project[]): Prom
|
||||
logger.ok('Tidied protected branches.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tidy protected tags
|
||||
*
|
||||
* @param api GitLab API instance to use for the requests
|
||||
* @param projects List of projects to tidy protected tags on
|
||||
*/
|
||||
export async function tidyProtectedTags(api: Api, projects: Project[]): Promise<void> {
|
||||
await asyncPool(2, projects, async (project) => {
|
||||
const protectedTags: Array<{
|
||||
create_access_levels: Array<{
|
||||
access_level: AccessLevel,
|
||||
access_level_description: string;
|
||||
}>;
|
||||
name: string;
|
||||
}> = await api.makeGitLabAPIRequest(`projects/${project.id}/protected_tags`);
|
||||
|
||||
if (!protectedTags.find((protectedTag) => {
|
||||
return protectedTag.name === 'v*';
|
||||
})) {
|
||||
await api.makeGitLabAPIRequest(`projects/${project.id}/protected_tags`, {
|
||||
data: {
|
||||
create_access_level: AccessLevel.Maintainer,
|
||||
name: 'v*',
|
||||
},
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
logger.log(`Added protected version tag in project '${project.name_with_namespace}'.`);
|
||||
}
|
||||
});
|
||||
|
||||
logger.ok('Tidied protected tags.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tidy "sub" group members
|
||||
*
|
||||
@@ -320,6 +347,7 @@ export async function tidy(api: Api) {
|
||||
tidyLabels(api, projects),
|
||||
tidyMilestones(api, projects),
|
||||
tidyProtectedBranches(api, projects),
|
||||
tidyProtectedTags(api, projects),
|
||||
tidySubGroupMembers(api),
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user