Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pstreef committed Aug 5, 2024
1 parent 7379755 commit d71427e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 29 deletions.
2 changes: 1 addition & 1 deletion rewrite-core/src/main/java/org/openrewrite/GitRemote.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public GitRemote parse(String url) {
} else {
repositoryPath = repositoryPath.replaceFirst("/_git/", "/");
}

break;
case Bitbucket:
if (url.startsWith("http")) {
repositoryPath = repositoryPath.replaceFirst("scm/", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
package org.openrewrite.marker;


import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.With;
import lombok.*;
import lombok.experimental.NonFinal;
import org.openrewrite.GitRemote;
import org.openrewrite.Incubating;
Expand All @@ -46,7 +43,7 @@
import static org.openrewrite.Tree.randomId;

@Value
@AllArgsConstructor
@AllArgsConstructor(access = AccessLevel.PACKAGE) // required for @With and tests
@RequiredArgsConstructor
@With
public class GitProvenance implements Marker {
Expand Down Expand Up @@ -93,9 +90,7 @@ public class GitProvenance implements Marker {
*
* @param baseUrl the portion of the URL which precedes the organization
* @return the portion of the git origin URL which corresponds to the organization the git repository is organized under
* @deprecated use {@link #getOrganizationName()} instead }
*/
@Deprecated
public @Nullable String getOrganizationName(String baseUrl) {
if (origin == null) {
return null;
Expand Down Expand Up @@ -141,14 +136,6 @@ public class GitProvenance implements Marker {
return getGitRemote().getOrigin();
}

public static String getRepositoryPath(String origin) {
return getRepositoryPath(origin, new GitRemote.Parser());
}

public static String getRepositoryPath(String origin, GitRemote.Parser parser) {
return parser.parse(origin).getPath();
}

/**
* @param projectDir The project directory.
* @return A marker containing git provenance information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.openrewrite.marker;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -73,20 +72,10 @@ private static Stream<Arguments> remotes() {
);
}

@ParameterizedTest
@MethodSource("remotes")
void getRepositoryPathWithBaseUrl(String origin, String expectedOrg, String expectedRepo) {
GitProvenance gitProvenance = new GitProvenance(randomId(), origin, "main", "123", null, null, List.of(), null);
assertThat(gitProvenance.getOrganizationName()).isEqualTo(expectedOrg);
assertThat(gitProvenance.getRepositoryName()).isEqualTo(expectedRepo);
String expectedPath = expectedOrg + '/' + expectedRepo;
assertThat(GitProvenance.getRepositoryPath(origin)).isEqualTo(expectedPath);
}

@ParameterizedTest
@MethodSource("remotes")
void getRepositoryPath(String origin, String expectedOrg, String expectedRepo) {
GitProvenance gitProvenance = new GitProvenance(randomId(), origin, "main", "123", null, null, List.of(), null);
GitProvenance gitProvenance = new GitProvenance(randomId(), origin, "main", "123", null, null, List.of());
assertThat(gitProvenance.getOrganizationName()).isEqualTo(expectedOrg);
assertThat(gitProvenance.getRepositoryName()).isEqualTo(expectedRepo);
String expectedPath = expectedOrg + '/' + expectedRepo;
Expand All @@ -96,7 +85,7 @@ void getRepositoryPath(String origin, String expectedOrg, String expectedRepo) {
@ParameterizedTest
@MethodSource("remotes")
void getRepositoryOrigin(String origin, String expectedOrg, String expectedRepo) {
GitProvenance gitProvenance = new GitProvenance(randomId(), origin, "main", "123", null, null, List.of(), null);
GitProvenance gitProvenance = new GitProvenance(randomId(), origin, "main", "123", null, null, List.of());
assertThat(gitProvenance.getOrganizationName()).isEqualTo(expectedOrg);
assertThat(gitProvenance.getRepositoryName()).isEqualTo(expectedRepo);
assertThat(gitProvenance.getOrigin()).isEqualTo(origin);
Expand Down

0 comments on commit d71427e

Please sign in to comment.