Skip to content

Commit

Permalink
DOP-4549-c hotfix check for empty group
Browse files Browse the repository at this point in the history
  • Loading branch information
anabellabuckvar committed May 9, 2024
1 parent 51032f4 commit 28e4ce7
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions api/handlers/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,47 @@ export async function buildEntitledGroupsList(entitlement: any, repoBranchesRepo
const repoOptions: any[] = [];
for (const repo of entitlement.repos) {
const [repoOwner, repoName, directoryPath] = repo.split('/');

const branches = await repoBranchesRepository.getRepoBranches(repoName, directoryPath);
const options: any[] = [];
for (const branch of branches) {
const buildWithSnooty = branch['buildsWithSnooty'];
if (buildWithSnooty) {
const active = branch['active'];
const branchName = `${directoryPath ? `${directoryPath}/` : ''}${branch['gitBranchName']}`;
const repoPath = `${repoOwner}/${repoName}/${branchName}`;
let txt: string;
if (!active) {
txt = `(!inactive) ${repoPath}`;
} else {
txt = repoPath;

if (branches.length) {
const options: any[] = [];
for (const branch of branches) {
const buildWithSnooty = branch['buildsWithSnooty'];
if (buildWithSnooty) {
const active = branch['active'];
const branchName = `${directoryPath ? `${directoryPath}/` : ''}${branch['gitBranchName']}`;
const repoPath = `${repoOwner}/${repoName}/${branchName}`;
let txt: string;
if (!active) {
txt = `(!inactive) ${repoPath}`;
} else {
txt = repoPath;
}
options.push({
text: {
type: 'plain_text',
text: txt,
},
value: repoPath,
});
}
options.push({
text: {
type: 'plain_text',
text: txt,
},
value: repoPath,
});
}
}

const repoOption = {
label: {
type: 'plain_text',
text: repoName,
},
//sort the options by version number
options: options.sort((branchOne, branchTwo) =>
branchTwo.text.text
.toString()
.replace(/\d+/g, (n) => +n + 100000)
.localeCompare(branchOne.text.text.toString().replace(/\d+/g, (n) => +n + 100000))
),
};
repoOptions.push(repoOption);
const repoOption = {
label: {
type: 'plain_text',
text: repoName,
},
//sort the options by version number
options: options.sort((branchOne, branchTwo) =>
branchTwo.text.text
.toString()
.replace(/\d+/g, (n) => +n + 100000)
.localeCompare(branchOne.text.text.toString().replace(/\d+/g, (n) => +n + 100000))
),
};
repoOptions.push(repoOption);
}
}
return repoOptions.sort((repoOne, repoTwo) => repoOne.label.text.localeCompare(repoTwo.label.text));
}
Expand Down

0 comments on commit 28e4ce7

Please sign in to comment.