Skip to content

Commit

Permalink
Merge pull request #415 from atomist/nortissej/custom-seed
Browse files Browse the repository at this point in the history
Allow people to fully override the seed repo
  • Loading branch information
johnsonr committed Jun 20, 2018
2 parents b918180 + 3ff8d21 commit ce0565d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
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
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
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

0 comments on commit ce0565d

Please sign in to comment.