UNPKG

@atomist/sdm

Version:

Atomist Software Delivery Machine SDK

43 lines 2.22 kB
"use strict"; /* * Copyright © 2020 Atomist, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.MaterialChangeToJavaRepo = exports.IsJava = void 0; const projectUtils = require("@atomist/automation-client/lib/project/util/projectUtils"); const logger_1 = require("@atomist/automation-client/lib/util/logger"); const filesChangedSince_1 = require("../../../api-helper/misc/git/filesChangedSince"); const PushTest_1 = require("../../../api/mapping/PushTest"); exports.IsJava = PushTest_1.predicatePushTest("Is Java", async (p) => projectUtils.fileExists(p, "**/*.java", () => true)); const FileToWatch = ["java", "html", "json", "yml", "yaml", "xml", "sh", "kt", "properties"]; /** * Veto if change to deployment unit doesn't seem important enough to * build and deploy */ exports.MaterialChangeToJavaRepo = PushTest_1.pushTest("Material change to Java repo", async (pci) => { const changedFiles = await filesChangedSince_1.filesChangedSince(pci.project, pci.push); if (!changedFiles) { logger_1.logger.info("Cannot determine if change is material on %j: can't enumerate changed files", pci.id); return true; } logger_1.logger.debug(`MaterialChangeToJavaRepo: Changed files are [${changedFiles.join(",")}]`); if (filesChangedSince_1.anyFileChangedWithExtension(changedFiles, FileToWatch)) { logger_1.logger.debug("Change is material on %j: changed files=[%s]", pci.id, changedFiles.join(",")); return true; } logger_1.logger.debug("Change is immaterial on %j: changed files=[%s]", pci.id, changedFiles.join(",")); return false; }); //# sourceMappingURL=pushTests.js.map