0

Image we have the below code snippet, I want to set this config before cloning a remote repo, but here cloneCommand.getRepository() has no repo yet as it's not cloned, so how I can set this value before the clone?

CloneCommand cloneCommand = Git.cloneRepository(`enter code here`).setURI(rempteRepo`enter code here`)
                    .setDirectory(new File(SF_COMPVRP_CODEBASE_LOCAL))
                    .setCredentialsProvider(new UsernamePasswordCredentialsProvider(this.gitHubUid, this.gitHubPwd));

StoredConfig config = cloneCommand.getRepository().getConfig();
            config.setBoolean("http", null, "sslVerify", false );
            config.save();
  • Possible duplicate of [Turn SSL verification off for JGit clone command](https://stackoverflow.com/questions/33998477/turn-ssl-verification-off-for-jgit-clone-command) – Rüdiger Herrmann Aug 10 '18 at 07:01

1 Answers1

0

Open the filesystem config first, manipulate that configuration (not sure if it persists it) and clone the repository.

        // https://stackoverflow.com/questions/33998477/turn-ssl-verification-off-for-jgit-clone-command
        /*
         * To work around this limitation, you can execute the specific clone steps
         * manually as suggested in the comments below:
         * 
         * init a repository using the InitCommand set ssl verify to false 
         * StoredConfig config = git.getRepository().getConfig(); 
         * config.setBoolean( "http", null, "sslVerify", false ); 
         * config.save(); 
         * fetch (see FetchCommand) 
         * checkout (see CheckoutCommand)
         */
        FileBasedConfig config = SystemReader.getInstance().openUserConfig( null, FS.DETECTED );
        Set<String> subSections = config.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION);
        config.save();

        //Git git = Git.init().setDirectory( localPath ).call();
        Git git = Git.cloneRepository().setURI(remoteUrl).setDirectory(localPath).call();

```

Bananaman
  • 131
  • 2
  • 3