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

Add git support for compatibility checker #17684

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

mannoopj
Copy link
Contributor

@mannoopj mannoopj commented Nov 4, 2024

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

@mannoopj mannoopj marked this pull request as draft November 4, 2024 14:59
@github-actions github-actions bot added tools build Gradle build or GitHub Actions generator RPC and Record code generator labels Nov 4, 2024
@mannoopj mannoopj marked this pull request as ready for review November 5, 2024 15:28
* @param contents The path to read the file from.
* @return The MessageSpec.
*/
static MessageSpec readMessageSpecFromString(String contents) {
Copy link
Contributor

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 {
Copy link
Contributor

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))));
Copy link
Contributor

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. ");
Copy link
Contributor

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),
Copy link
Contributor

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;
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Gradle build or GitHub Actions generator RPC and Record code generator tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants