HorizonNet commented on a change in pull request #248: NIFIREG-227 GitFlowPersistenceProvider option to clone repo on startup URL: https://github.com/apache/nifi-registry/pull/248#discussion_r350401315
########## File path: nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowMetaData.java ########## @@ -136,36 +136,50 @@ private Repository openRepository(final File gitProjectRootDir) throws IOExcepti } private static boolean hasAtLeastOneReference(Repository repo) { - logger.info(repo.toString()); + logger.info("Checking references for repository {}", repo.toString()); for (Ref ref : repo.getAllRefs().values()) { - if (ref.getObjectId() == null) + if (ref.getObjectId() == null) { continue; + } return true; } return false; } + /** + * Check if provided local repository exists or not at given 'Flow Storage Directory' in providers.xml + * @param localRepo file object of 'Flow Storage Directory' + * @return true if local repository exists else false + * @throws IOException if .git of local repository cannot be opened + */ public boolean localRepoExists(File localRepo) throws IOException { if (!localRepo.isDirectory()) { logger.info("{} is not a directory or does not exist.", localRepo.getPath()); return false; } if (RepositoryCache.FileKey.isGitRepository(new File(localRepo.getPath()+"/.git"), FS.DETECTED)) { - Git git = Git.open(new File(localRepo.getPath() + "/.git")); - Repository repository = git.getRepository(); + final Git git = Git.open(new File(localRepo.getPath() + "/.git")); + final Repository repository = git.getRepository(); logger.info("Checking for git references in {}", localRepo.getPath()); - boolean referenceExists = hasAtLeastOneReference(repository); - if (referenceExists) + final boolean referenceExists = hasAtLeastOneReference(repository); + if (referenceExists) { logger.info("{} local repository exists with references so no need to clone remote", localRepo.getPath()); + } // Can be an empty repository if no references are present should we pull from remote? return true; } return false; } + /** + * Validate if provided 'Remote Clone Repository' in providers.xml exists or not. If remote repository + * doesn't exist then will throw IllegalArgumentException + * @param remoteRepository URI value of 'Remote Clone Repository' Review comment: Better: the URI value of the 'Remote Clone Repository' configuration ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services