Skip to content

Commit

Permalink
fix playbook loader
Browse files Browse the repository at this point in the history
  • Loading branch information
fantkolja committed Nov 29, 2024
1 parent 938ff1c commit 985c959
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions lib/load-check-links-playbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,31 @@ function rewriteCurrentVersion() {
}
}

function excludeBaseBranch(sources, repoName, branchName) {
const matchedRepos = sources.filter(source => source.url.endsWith(repoName));
if (matchedRepos.length === 0) {
throw new Error(`There is no repository ${repoName} among the playbook sources!`);
}
let currentSource = matchedRepos.find(source => isMatch(branchName, source.branches));
function getCurrentSource(matchedRepos, branchName) {
let currentSource = matchedRepos.find(source => {
if (Array.isArray(source.branches)) {
return source.branches.find(branch => isMatch(branchName, branch));
} else {
return isMatch(branchName, source.branches);
}
});
if (!currentSource) {
console.debug(`No matching base branch found. Rewriting version to omit version collision!`);
rewriteCurrentVersion();
currentSource = matchedRepos[0];
}

return currentSource;
}

function excludeBaseBranch(sources, repoName, branchName) {
const excludedBranch = `!${branchName}`;
const matchedRepos = sources.filter(source => source.url.endsWith(repoName));
if (matchedRepos.length === 0) {
throw new Error(`There is no repository ${repoName} among the playbook sources!`);
}

const currentSource = getCurrentSource(matchedRepos, branchName);
if (Array.isArray(currentSource.branches)) {
currentSource.branches.push(excludedBranch);
} else {
Expand Down

0 comments on commit 985c959

Please sign in to comment.