|
18 | 18 | import org.junit.jupiter.api.Nested; |
19 | 19 | import org.junit.jupiter.api.Test; |
20 | 20 | import org.openrewrite.DocumentExample; |
| 21 | +import org.openrewrite.Issue; |
21 | 22 | import org.openrewrite.marker.GitProvenance; |
22 | 23 | import org.openrewrite.test.RecipeSpec; |
23 | 24 | import org.openrewrite.test.RewriteTest; |
24 | 25 |
|
25 | 26 | import java.util.UUID; |
26 | 27 |
|
| 28 | +import static org.openrewrite.java.Assertions.mavenProject; |
27 | 29 | import static org.openrewrite.maven.Assertions.pomXml; |
28 | 30 |
|
29 | 31 | class UpdateScmFromGitOriginTest implements RewriteTest { |
@@ -460,6 +462,62 @@ void stillUpdatesExistingScmWhenAddIfMissingIsTrue() { |
460 | 462 | ) |
461 | 463 | ); |
462 | 464 | } |
| 465 | + |
| 466 | + @Issue("https://github.com/openrewrite/rewrite/issues/5812") |
| 467 | + @Test |
| 468 | + void addsScmToRootPomOnly() { |
| 469 | + rewriteRun( |
| 470 | + spec -> spec.recipe(new UpdateScmFromGitOrigin(true)), |
| 471 | + mavenProject("parent", |
| 472 | + pomXml( |
| 473 | + """ |
| 474 | + <project> |
| 475 | + <modelVersion>4.0.0</modelVersion> |
| 476 | + <groupId>com.mycompany.app</groupId> |
| 477 | + <artifactId>my-app-parent</artifactId> |
| 478 | + <version>1</version> |
| 479 | + <packaging>pom</packaging> |
| 480 | + <modules> |
| 481 | + <module>module1</module> |
| 482 | + </modules> |
| 483 | + </project> |
| 484 | + """, |
| 485 | + """ |
| 486 | + <project> |
| 487 | + <modelVersion>4.0.0</modelVersion> |
| 488 | + <groupId>com.mycompany.app</groupId> |
| 489 | + <artifactId>my-app-parent</artifactId> |
| 490 | + <version>1</version> |
| 491 | + <packaging>pom</packaging> |
| 492 | + <modules> |
| 493 | + <module>module1</module> |
| 494 | + </modules> |
| 495 | + <scm> |
| 496 | + <url>https://github.com/example/repo</url> |
| 497 | + <connection>scm:git:https://github.com/example/repo.git</connection> |
| 498 | + <developerConnection>scm:git:git@github.com:example/repo.git</developerConnection> |
| 499 | + </scm> |
| 500 | + </project> |
| 501 | + """, |
| 502 | + spec -> spec.markers(gitProvenance("https://github.com/example/repo.git")) |
| 503 | + ), |
| 504 | + mavenProject("module1", |
| 505 | + pomXml( |
| 506 | + """ |
| 507 | + <project> |
| 508 | + <modelVersion>4.0.0</modelVersion> |
| 509 | + <parent> |
| 510 | + <groupId>com.mycompany.app</groupId> |
| 511 | + <artifactId>my-app-parent</artifactId> |
| 512 | + <version>1</version> |
| 513 | + </parent> |
| 514 | + <artifactId>module1</artifactId> |
| 515 | + </project> |
| 516 | + """ |
| 517 | + )) |
| 518 | + ) |
| 519 | + ); |
| 520 | + } |
463 | 521 | } |
464 | 522 |
|
465 | 523 | @Nested |
|
0 commit comments