Skip to content

Commit

Permalink
Expose a port number of remoteUrl in the mirror UI
Browse files Browse the repository at this point in the history
Motivation:

I found that the port number of the remote URI was missing and was shown
in the mirror UI.

Modifications:

- Use `URI.getAuthority()` to include the port number of a remote URI.

Result:

The custom port number of a remote URI is correctly displayed in the mirror UI.
  • Loading branch information
ikhoon committed Dec 11, 2024
1 parent b0d7708 commit 3110d1d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,40 @@ private void createAndReadMirror() {
final MirrorDto savedMirror = response1.content();
assertThat(savedMirror).isEqualTo(newMirror);
}

// Make sure that the mirror with a port number in the remote URL can be created and read.
final MirrorDto mirrorWithPort = new MirrorDto("mirror-with-port-3",
true,
FOO_PROJ,
"5 * * * * ?",
"REMOTE_TO_LOCAL",
BAR_REPO,
"/updated/local-path/",
"git+https",
"git.com:922/line/centraldogma-test.git",
"/updated/remote-path/",
"updated-mirror-branch",
".updated-env",
"public-key-credential",
null);

final ResponseEntity<PushResultDto> response0 =
userClient.prepare()
.post("/api/v1/projects/{proj}/mirrors")
.pathParam("proj", FOO_PROJ)
.contentJson(mirrorWithPort)
.asJson(PushResultDto.class)
.execute();
assertThat(response0.status()).isEqualTo(HttpStatus.CREATED);
final ResponseEntity<MirrorDto> response1 =
userClient.prepare()
.get("/api/v1/projects/{proj}/mirrors/{id}")
.pathParam("proj", FOO_PROJ)
.pathParam("id", mirrorWithPort.id())
.asJson(MirrorDto.class)
.execute();
final MirrorDto savedMirror = response1.content();
assertThat(savedMirror).isEqualTo(mirrorWithPort);
}

private void updateMirror() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private static MirrorDto convertToMirrorDto(String projectName, Mirror mirror) {
mirror.localRepo().name(),
mirror.localPath(),
remoteRepoUri.getScheme(),
remoteRepoUri.getHost() + remoteRepoUri.getPath(),
remoteRepoUri.getAuthority() + remoteRepoUri.getPath(),
mirror.remotePath(),
mirror.remoteBranch(),
mirror.gitignore(),
Expand Down

0 comments on commit 3110d1d

Please sign in to comment.