MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / shouldExcludeProject

Function shouldExcludeProject

packages/backend/src/gerrit.ts:106–152  ·  view source on GitHub ↗
({
   project,
   exclude,
}: {
   project: GerritProject,
   exclude?: GerritConnectionConfig['exclude'],
})

Source from the content-addressed store, hash-verified

104};
105
106const shouldExcludeProject = ({
107 project,
108 exclude,
109}: {
110 project: GerritProject,
111 exclude?: GerritConnectionConfig['exclude'],
112}) => {
113 let reason = '';
114
115 const shouldExclude = (() => {
116 if ([
117 'All-Projects',
118 'All-Users',
119 'All-Avatars',
120 'All-Archived-Projects'
121 ].includes(project.name)) {
122 reason = `Project is a special project.`;
123 return true;
124 }
125
126 if (!!exclude?.readOnly && project.state === 'READ_ONLY') {
127 reason = `\`exclude.readOnly\` is true`;
128 return true;
129 }
130
131 if (!!exclude?.hidden && project.state === 'HIDDEN') {
132 reason = `\`exclude.hidden\` is true`;
133 return true;
134 }
135
136 if (exclude?.projects) {
137 if (micromatch.isMatch(project.name, exclude.projects)) {
138 reason = `\`exclude.projects\` contains ${project.name}`;
139 return true;
140 }
141 }
142
143 return false;
144 })();
145
146 if (shouldExclude) {
147 logger.debug(`Excluding project ${project.name}. Reason: ${reason}`);
148 return true;
149 }
150
151 return false;
152}

Callers 1

getGerritReposFromConfigFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected