Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow people to fully override the seed repo #415

Merged
merged 3 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased][]

[Unreleased]: https://github.com/atomist/sdm/compare/0.1.0...HEAD
[Unreleased]: https://github.com/atomist/sdm/compare/0.2.3...HEAD

### BREAKING

- SeedDrivenGeneratorSupport allows you to override the seed. This fixes a bug with overriding the seed name,
and also adds the ability to override the owner. Only GitHub repositories are supported.
This changes the type of GeneratorConfig.seed; give it a function that returns a _new_ seed repoRef, instead of a constant one.

## Earlier

### Added

Expand Down
2 changes: 1 addition & 1 deletion src/api/command/generator/GeneratorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface GeneratorConfig {
/**
* The seed repo
*/
seed: RemoteRepoRef;
seed: () => RemoteRepoRef;

/**
* Add an Atomist webhook to new repos?
Expand Down
17 changes: 14 additions & 3 deletions src/api/command/generator/SeedDrivenGeneratorParametersSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,25 @@ export class SeedDrivenGeneratorParametersSupport implements SeedDrivenGenerator
public version: string = "0.1.0-SNAPSHOT";

@Parameter({
displayName: "Seed repo",
description: "Seed repo",
displayName: "Seed repository override",
description: "Seed repository name",
...GitHubNameRegExp,
minLength: 1,
maxLength: 50,
required: false,
})
public seed: string;

@Parameter({
displayName: "Seed repository owner override",
description: "Seed repository owner",
...GitHubNameRegExp,
minLength: 1,
maxLength: 50,
required: false,
})
public seedOwner: string;

public target: NewRepoCreationParameters = new GitHubRepoCreationParameters();

@MappedParameter(MappedParameters.SlackTeam)
Expand All @@ -76,8 +86,9 @@ export class SeedDrivenGeneratorParametersSupport implements SeedDrivenGenerator
* @return {RemoteLocator}
*/
get source(): RemoteLocator {
const repoRef = this.config.seed;
const repoRef = this.config.seed();
repoRef.repo = this.seed || repoRef.repo;
repoRef.owner = this.seedOwner || repoRef.owner;
return {repoRef};
}

Expand Down