-
Notifications
You must be signed in to change notification settings - Fork 14k
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
Add git support for compatibility checker #17684
base: trunk
Are you sure you want to change the base?
Conversation
* @param contents The path to read the file from. | ||
* @return The MessageSpec. | ||
*/ | ||
static MessageSpec readMessageSpecFromString(String contents) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to create a file to translate a string to a MessageSpec, we can do this directly.
* @param fileCheckMetadata The file to read from remote git repo. | ||
* @return The file contents. | ||
*/ | ||
static String GetDataFromGit(String fileCheckMetadata) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the parameter is named fileCheckMetadata
, can you explain?
try (TreeWalk treeWalk = new TreeWalk(repository)) { | ||
treeWalk.addTree(tree); | ||
treeWalk.setRecursive(true); | ||
treeWalk.setFilter(PathFilter.create(String.valueOf(Paths.get("metadata/src/main/resources/common/metadata/" + fileCheckMetadata)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use a constant for metadata/src/main/resources/common/metadata
@@ -56,6 +73,11 @@ public static void run( | |||
evolutionVerifierParser.addArgument("--path2", "-2"). | |||
required(true). | |||
help("The final schema JSON path."); | |||
Subparser evolutionGitVerifierParser = subparsers.addParser("verify-evolution-git"). | |||
help(" Verify that an evolution of a JSon file is valid using git. "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSon
?
String fileCheckMetadata = namespace.getString("file"); | ||
String gitContent = GetDataFromGit(fileCheckMetadata); | ||
EvolutionVerifier verifier = new EvolutionVerifier( | ||
CheckerUtils.readMessageSpecFromFile(Paths.get("").toAbsolutePath().getParent() + "/metadata/src/main/resources/common/metadata/" + fileCheckMetadata), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general I don't understand what the strategy is here for paths. if you are using a relative path, you need to document what directory we need to be in. how are we locating the git repository root?
@@ -37,6 +37,8 @@ | |||
|
|||
import static net.sourceforge.argparse4j.impl.Arguments.store; | |||
|
|||
import org.eclipse.jgit.api.Git; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this import needed here?
Add git support for schema compatibility checker. Pulls in valid schema from remote git trunk branch to check with edited schema in local branch. Adds new option for command line
verify-evolution-git
which takes in a required file name