Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
Add scan command
Browse files Browse the repository at this point in the history
* make sure it iterates over each configuration
  • Loading branch information
slimslenderslacks committed Sep 11, 2020
1 parent abb911a commit 57781c7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
36 changes: 12 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var api = require("@atomist/api-cljs/atomist.middleware");

var configureReviews = function(request) {
var configureReviews = (request) => {
if (request.required_approving_review_count || request.require_code_owner_reviews || request.dismiss_stale_reviews) {
return {
... (request.required_approving_review_count && {required_approving_review_count: request.required_approving_review_count}),
Expand All @@ -12,7 +12,7 @@ var configureReviews = function(request) {
}
};

var convergeBranchRules = async function (request, branch, repo) {
var convergeBranchRules = async (request, repo, branch) => {
if (
request.topic &&
repo.topics &&
Expand All @@ -35,41 +35,29 @@ var convergeBranchRules = async function (request, branch, repo) {
return true;
};

var scan = async (request) => {
// await request.withRepoIterator(async (repo) => {
// return await repo.withBranches(async (branches) => {
// return await Promise.all(branches.map(async branch => {
// console.info(`check ${branch} on ${repo.owner}/${repo.repo}`);
// return await convergeBranchRules(
// request,
// branch,
// repo
// );
// }));
// });
// });
console.info(JSON.stringify(request));
};

exports.handler = api.handler({
OnAnyPush: async (request) => {
await request.withRepo(async (repo) => {
return await convergeBranchRules(
request,
request.data.Push[0].branch,
repo
repo,
request.data.Push[0].branch
);
});
},
OnPullRequest: async (request) => {
await request.withRepo(async (repo) => {
return await convergeBranchRules(
request,
request.data.PullRequest[0].baseBranchName,
repo
repo,
request.data.PullRequest[0].baseBranchName
);
});
},
sync: scan,
OnSchedule: scan
sync: api.scanBranches(async (request, repo, branch) => {
return await api.eachConfig(request, async (req) => {
return await convergeBranchRules(req, repo, branch);
});
}),
OnSchedule: api.scanBranches(convergeBranchRules)
});
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"atm:lint:prettier": "prettier --write"
},
"dependencies": {
"@atomist/api-cljs": "^0.4.101"
"@atomist/api-cljs": "^0.4.102"
},
"main": "node_modules/@atomist/api-cljs/app.js",
"devDependencies": {
Expand Down

0 comments on commit 57781c7

Please sign in to comment.