forked from line/centraldogma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to show project creators correctly (line#909)
Motivation: The current creator of a project is the creator of the internal `dogma` repository, consistently set as `System`. We should show the correct creator which is stored in the `metadata.json` file. A noteworthy observation is that only the email of the creator is stored in `metadata.json` instead of the complete `Author` information. A temporary solution involves restoring the `Author` using the email, with plans to revisit this approach if issues arise. Modifications: - Fix to show project creators correctly using information stored in the `metadata.json` file. Result: - Close line#908 - The project creator is now correctly retrieved based on the information stored in the `metadata.json` file.
- Loading branch information
Showing
8 changed files
with
78 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ | |
@State(Scope.Benchmark) | ||
public class GitRepositoryBenchmark { | ||
|
||
private static final Author AUTHOR = new Author("[email protected]"); | ||
private static final Author AUTHOR = Author.ofEmail("[email protected]"); | ||
|
||
@Param({ "0", "2000", "4000", "6000", "8000" }) | ||
private int previousCommits; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
package com.linecorp.centraldogma.common; | ||
|
||
import static com.linecorp.centraldogma.internal.Util.emailToUsername; | ||
import static java.util.Objects.requireNonNull; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
|
@@ -43,12 +44,23 @@ public class Author { | |
*/ | ||
public static final Author UNKNOWN = new Author("Unknown", "[email protected]"); | ||
|
||
/** | ||
* Create a new {@link Author} with the {@code email}. | ||
* The {@link #name()} will be set to the username of the {@code email}. | ||
*/ | ||
public static Author ofEmail(String email) { | ||
return new Author(emailToUsername(email, "email"), email); | ||
} | ||
|
||
private final String name; | ||
private final String email; | ||
|
||
/** | ||
* Creates a new instance with the specified e-mail address. | ||
* | ||
* @deprecated Use {@link #ofEmail(String)}. | ||
*/ | ||
@Deprecated | ||
public Author(String email) { | ||
this(email, email); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,9 +42,9 @@ void testJsonConversion() { | |
" \"email\": \"[email protected]\"" + | ||
'}'); | ||
|
||
TestUtil.assertJsonConversion(new Author("[email protected]"), | ||
TestUtil.assertJsonConversion(Author.ofEmail("[email protected]"), | ||
'{' + | ||
" \"name\": \"bart@simpsonsworld.com\"," + | ||
" \"name\": \"bart\"," + | ||
" \"email\": \"[email protected]\"" + | ||
'}'); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,8 +52,8 @@ class TokenServiceTest { | |
@RegisterExtension | ||
static final ProjectManagerExtension manager = new ProjectManagerExtension(); | ||
|
||
private static final Author adminAuthor = new Author("[email protected]"); | ||
private static final Author guestAuthor = new Author("[email protected]"); | ||
private static final Author adminAuthor = Author.ofEmail("[email protected]"); | ||
private static final Author guestAuthor = Author.ofEmail("[email protected]"); | ||
private static final User admin = new User("[email protected]", User.LEVEL_ADMIN); | ||
private static final User guest = new User("[email protected]"); | ||
private static final JsonNode activation = Jackson.valueToTree( | ||
|