Skip to content

Commit

Permalink
Add pushStrategy parameters helper
Browse files Browse the repository at this point in the history
[changelog:added]
  • Loading branch information
cdupuis committed Jun 22, 2020
1 parent 1d6dabe commit 42535da
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
43 changes: 42 additions & 1 deletion lib/definition/parameter/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { ParameterType, RepoFilterParameter } from "../skill";
import { ParameterType, RepoFilterParameter, SingleChoiceParameter } from "../skill";

export function repoFilter(options: { required?: boolean } = { required: true }): RepoFilterParameter {
return {
Expand All @@ -24,3 +24,44 @@ export function repoFilter(options: { required?: boolean } = { required: true })
required: options.required !== undefined ? options.required : true,
};
}

export type PushStrategy = "pr_default_commit" | "pr_default" | "pr" | "commit_default" | "commit";

export function pushStrategy(options: {
displayName: string;
description: string;
required?: boolean;
defaultValue?: string;
options?: SingleChoiceParameter["options"];
}): SingleChoiceParameter {
return {
type: ParameterType.SingleChoice,
displayName: options.displayName,
description: options.description,
defaultValue: options.defaultValue ? options.defaultValue : "pr_default_commit",
options: [
{
text: "Raise pull request for default branch; commit to other branches",
value: "pr_default_commit",
},
{
text: "Raise pull request for default branch only",
value: "pr_default",
},
{
text: "Raise pull request for any branch",
value: "pr",
},
{
text: "Commit to default branch only",
value: "commit_default",
},
{
text: "Commit to any branch",
value: "commit",
},
...(options.options || []),
],
required: options.required !== undefined ? options.required : false,
};
}
2 changes: 1 addition & 1 deletion lib/definition/parameter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/

export { repoFilter } from "./definition";
export { repoFilter, PushStrategy, pushStrategy } from "./definition";

0 comments on commit 42535da

Please sign in to comment.