mirror of
https://github.com/Joxit/docker-registry-ui.git
synced 2026-05-23 04:42:47 +00:00
test(branching): start new configurable branching repository system
This commit is contained in:
27
src/scripts/repositories.js
Normal file
27
src/scripts/repositories.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const getRepositoryName = (split, max) => {
|
||||
let repositoryName = '';
|
||||
for (let i = 0; i < max; i++) {
|
||||
repositoryName += `${split[i]}/`;
|
||||
}
|
||||
return repositoryName;
|
||||
};
|
||||
|
||||
export const getBranching =
|
||||
(min = 1, max = 1) =>
|
||||
(repositories) =>
|
||||
repositories.sort().reduce(function (acc, image) {
|
||||
const split = image.split('/');
|
||||
if (split.length > min && min > 0) {
|
||||
const repoName = getRepositoryName(split, max);
|
||||
if (acc.length === 0 || acc[acc.length - 1].repo != repoName) {
|
||||
acc.push({
|
||||
repo: repoName,
|
||||
images: [],
|
||||
});
|
||||
}
|
||||
acc[acc.length - 1].images.push(image);
|
||||
return acc;
|
||||
}
|
||||
acc.push(image);
|
||||
return acc;
|
||||
}, []);
|
||||
Reference in New Issue
Block a user