Skip to content
This repository has been archived by the owner on Mar 19, 2019. It is now read-only.

Commit

Permalink
Merge pull request #308 from atomist/dups
Browse files Browse the repository at this point in the history
Don't duplicate implicit parameters in calling editor/generator #258
  • Loading branch information
kipz authored Feb 9, 2017
2 parents 3f3acc0 + 574c35a commit 2006451
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Added `ScalaFileType` backed by ScalaMeta


### Fixed

- Fix: Elm parser failed on files with two multiline comments
https://github.com/atomist/rug/issues/268
https://github.com/atomist/rug/issues/268

- Raise an `InvalidRugTestScenarioName` when a Rug test scenario is missing a name #71


- Implicit DLS parameters (from `uses`) are no longer duplicate if multiple
editors declare the same parameter. The first one is chosen.
https://github.com/atomist/rug/issues/258

### Changed

- Upgrade TS compiler to 2.1.5
Expand Down
11 changes: 7 additions & 4 deletions src/main/scala/com/atomist/param/ParameterizedSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ trait ParameterizedSupport extends Parameterized {

override final def parameters: Seq[Parameter] = params.filterNot(_ == null)

protected def addParameter(tp: Parameter): Unit =
params += tp
protected def addParameter(tp: Parameter): Unit = {
if(!params.exists(p => tp.name == p.name)){
params += tp
}
}

protected def addParameters(tps: Seq[Parameter]): Unit = tps.foreach(p => addParameter(p))

protected def addParameters(tps: Seq[Parameter]): Unit =
params ++= tps
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ProjectOperationArchiveReaderTest extends FlatSpec with Matchers {
""".stripMargin
)


val EditorWithImports = StringFileArtifact(atomistConfig.editorsRoot + "/EditorWithImports.rug",
"""
|editor EditorWithImports
Expand All @@ -52,6 +53,46 @@ class ProjectOperationArchiveReaderTest extends FlatSpec with Matchers {
""".stripMargin
)

val EditorWithProjectName = StringFileArtifact(atomistConfig.editorsRoot + "/Stuff.rug",
"""
|editor Stuff
|
|param project_name: ^.*$
|
|with File f do setPath ""
""".stripMargin
)

val AnotherEditorWithProjectName = StringFileArtifact(atomistConfig.editorsRoot + "/MoreStuff.rug",
"""
|editor MoreStuff
|
|param project_name: ^.*$
|
|with File f do setPath ""
""".stripMargin
)

val GeneratorWithoutProjectName = StringFileArtifact(atomistConfig.editorsRoot + "/Published.rug",
"""
|generator Published
|
|uses Stuff
|uses MoreStuff
|
|Stuff
|MoreStuff
""".stripMargin
)

//https://github.com/atomist/rug/issues/258
it should "only describe a single project_name parameter if it's declared" in {
val apc = new ProjectOperationArchiveReader(atomistConfig)
val ops = apc.findOperations(new SimpleFileBasedArtifactSource("", Seq(GeneratorWithoutProjectName, EditorWithProjectName, AnotherEditorWithProjectName)), None, Nil)
assert(ops.generators.size === 1)
assert(ops.generators.head.parameters.size === 1)
}

it should "parse single editor" in {
val apc = new ProjectOperationArchiveReader(atomistConfig)
val ops = apc.findOperations(new SimpleFileBasedArtifactSource("", FirstEditor), None, Nil)
Expand Down

0 comments on commit 2006451

Please sign in to comment.