Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix history displays irrelevant changes #922

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public final class HttpApiV1Constants {

public static final String PROJECTS_PREFIX = API_V1_PATH_PREFIX + PROJECTS;

public static final String PROJECTS_VO_PREFIX = API_V0_PATH_PREFIX + PROJECTS;

public static final String REPOS = "/repos";

public static final String COMMITS = "/commits";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ public CompletionStage<List<CommitDto>> getHistory(@Param String projectName,
@Param String path,
@Param @Default("-1") String from,
@Param @Default("1") String to) {
final String pathPattern = "/".equals(path) ? "/**" : path + "/**";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other APIs we have (e.g. watch*, diff*) don't add a slash at the end.
For consistency, I think it would be better that all APIs that accept a pathPattern have the same behavior.
Also, I think it is perfectly valid to watch /a** depending on the use-case.

Question) What do you think of fixing this issue from the client side instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jrhee17, about fixing this issue from the client side, do you mean we receive the list result from the client and filter?
From my side, it is not good to do logic on the client side.
@minwoox How do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about the late reply. Yeah, I also thought we should fix the UI (which is the client) to call the path correctly when I first created the issue.
We should let users retrieve whatever history they want so I think we should touch it on the server-side.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sound good @minwoox, could you provide me the screenshot to explain expected from client? I am happy to finish this 🚀

return projectApiManager.getProject(projectName).repos().get(repoName)
.history(new Revision(from),
new Revision(to),
path + "**")
pathPattern)
.thenApply(commits -> commits.stream()
.map(DtoConverter::convert)
.collect(toList()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.linecorp.centraldogma.server.internal.admin.service;

import com.fasterxml.jackson.databind.JsonNode;
import com.linecorp.armeria.client.WebClient;
import com.linecorp.armeria.client.WebClientBuilder;
import com.linecorp.armeria.common.AggregatedHttpResponse;
import com.linecorp.armeria.common.HttpHeaderNames;
import com.linecorp.centraldogma.internal.Jackson;
import com.linecorp.centraldogma.testing.junit.CentralDogmaExtension;
import com.linecorp.centraldogma.testing.junit4.CentralDogmaRule;
import org.junit.ClassRule;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.io.IOException;

import static org.assertj.core.api.Assertions.*;

class RepositoryServiceTest {

@RegisterExtension
static final CentralDogmaExtension dogma = new CentralDogmaExtension() {
@Override
protected void configureHttpClient(WebClientBuilder builder) {
builder.addHeader(HttpHeaderNames.AUTHORIZATION, "Bearer anonymous");
}
};

@Test
void getUsersInfo() throws IOException {
final WebClient client = dogma.httpClient();
final AggregatedHttpResponse userInfo = client.get("/api/v0/users/me").aggregate().join();
final JsonNode jsonNode = Jackson.readTree(userInfo.contentUtf8());
assertThat(jsonNode.get("login").asText()).isEqualTo("[email protected]");
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minwoox here, I try to add tests for the class RepositoryServiceTest, but it always returns 404 for /api/v0 (I try users/me to make sure I am correct ^^)
Do you know how to start the /api/v0 dogma for the test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's activated only when the webAppEnabled is true.


By the way, could you tell me why you need to retrieve the user information?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @minwoox, I can call /api/v0 now.
I just do the simplest test with api/v0 to explain to you my problem 🤩

}
Loading