UNPKG

@atomist/atomist-sdm

Version:

Atomist SDM to deliver our own projects

87 lines 3.91 kB
"use strict"; /* * Copyright © 2018 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. */ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); const automation_client_1 = require("@atomist/automation-client"); /** * Allow user to specify a branch (with default master). * Set 'newBranch' to true to create a unique new branch. */ let RequestedCommitParameters = class RequestedCommitParameters { constructor(commitMessage) { this.branch = "master"; // TODO should really be a boolean, investigate client issue this.newBranch = "false"; this.commitMessage = "Command handler commit from Atomist"; this.presentAs = "branch"; if (!!commitMessage) { this.commitMessage = commitMessage; } } get branchToUse() { if (!!this.branchUsed) { return this.branchUsed; } this.branchUsed = this.newBranch === "true" ? "atomist-" + new Date().getTime() : this.branch; return this.branchUsed; } get editMode() { switch (this.presentAs) { case "pr": return new automation_client_1.editModes.PullRequest(this.branchToUse, this.commitMessage, this.commitMessage); case "branch": const bc = { branch: this.branchToUse, message: this.commitMessage }; return bc; } } }; __decorate([ automation_client_1.Parameter(Object.assign({ required: false, description: "Branch to use. Default is 'master'." }, automation_client_1.validationPatterns.GitBranchRegExp)), __metadata("design:type", String) ], RequestedCommitParameters.prototype, "branch", void 0); __decorate([ automation_client_1.Parameter({ required: false, pattern: /(true|false)/ }), __metadata("design:type", String) ], RequestedCommitParameters.prototype, "newBranch", void 0); __decorate([ automation_client_1.Parameter({ required: false }), __metadata("design:type", String) ], RequestedCommitParameters.prototype, "commitMessage", void 0); __decorate([ automation_client_1.Parameter({ required: false, pattern: /^(pr|branch)$/, validInput: "How to present commit: 'pr' or 'branch', defaults to 'branch'", }), __metadata("design:type", String) ], RequestedCommitParameters.prototype, "presentAs", void 0); RequestedCommitParameters = __decorate([ automation_client_1.Parameters(), __metadata("design:paramtypes", [String]) ], RequestedCommitParameters); exports.RequestedCommitParameters = RequestedCommitParameters; //# sourceMappingURL=RequestedCommitParameters.js.map