public static Git cloneRemoteRepository ( String remoteName , String remoteUrl , String branch , GitAuthenticationConfigurator authConfigurator , File localFolder , String bigFileThreshold , Integer compression , Boolean fileMode ) throws GitAPIException , IOException { CloneCommand command = Git . cloneRepository ( ) ; command . setRemote ( remoteName ) ; command . setURI ( remoteUrl ) ; command . setDirectory ( localFolder ) ; if ( StringUtils . isNotEmpty ( branch ) ) { command . setCloneAllBranches ( false ) ; command . setBranchesToClone ( Collections . singletonList ( Constants . R_HEADS + branch ) ) ; command . setBranch ( branch ) ; } if ( authConfigurator != null ) { authConfigurator . configureAuthentication ( command ) ; } Git git = command . call ( ) ; StoredConfig config = git . getRepository ( ) . getConfig ( ) ; if ( StringUtils . isEmpty ( bigFileThreshold ) ) { bigFileThreshold = BIG_FILE_THRESHOLD_DEFAULT ; } if ( compression == null ) { compression = COMPRESSION_DEFAULT ; } if ( fileMode == null ) { fileMode = FILE_MODE_DEFAULT ; } config . setString ( CORE_CONFIG_SECTION , null , BIG_FILE_THRESHOLD_CONFIG_PARAM , bigFileThreshold ) ; config . setInt ( CORE_CONFIG_SECTION , null , COMPRESSION_CONFIG_PARAM , compression ) ; config . setBoolean ( CORE_CONFIG_SECTION , null , FILE_MODE_CONFIG_PARAM , fileMode ) ; config . save ( ) ; return git ; }
Clones a remote repository into a specific local folder .