本文整理匯總了Java中org.eclipse.jgit.api.CloneCommand.setBranchesToClone方法的典型用法代碼示例。如果您正苦於以下問題:Java CloneCommand.setBranchesToClone方法的具體用法?Java CloneCommand.setBranchesToClone怎麽用?Java CloneCommand.setBranchesToClone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jgit.api.CloneCommand
的用法示例。
在下文中一共展示了CloneCommand.setBranchesToClone方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: cloneRepo
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
/**
*
* Clones a git repository using the given uri and stores it in the parent directory. Checks out the
* given reference or (if value is null) does not check out a branch
* (which reduces time needed to complete command).
* @param cloneURI the uri to the remote repository
* @param parentDirectory the directory in which to store the git meta directory (".git" directory)
* @param checkoutRef the ref name ("refs/heads/master"), branch name ("master") or tag name ("v1.2.3"). If
* {@code null} is passed, will not checkout a branch.
* @param branchesToClone the branches to clone or all branches if passed a {@code null} value.
* @param monitor reports the progress of the clone command; can be null
* @return the cloned Git repository
* @throws GitAPIException
*/
public static Git cloneRepo(String cloneURI, File parentDirectory, String remoteName,
String checkoutRef, List<String> branchesToClone, ProgressMonitor monitor) throws GitAPIException {
CloneCommand clone = Git.cloneRepository();
if (checkoutRef == null) {
clone.setNoCheckout(true);
} else {
clone.setBranch(checkoutRef);
}
if (branchesToClone == null) {
clone.setCloneAllBranches(true);
} else {
clone.setBranchesToClone(branchesToClone);
}
if (monitor != null) { clone.setProgressMonitor(monitor); }
return clone
.setURI(cloneURI)
.setDirectory(parentDirectory)
.setRemote(remoteName)
.call();
}
示例2: execute
import org.eclipse.jgit.api.CloneCommand; //導入方法依賴的package包/類
@Override
public void execute() {
try {
CloneCommand cloneCommand = new CloneCommand();
if (branchToTrack != null) {
cloneCommand.setBranch(branchToTrack);
}
if (!branchNames.isEmpty()) {
cloneCommand.setBranchesToClone(branchNames);
}
cloneCommand.setURI(getUri()).
setBare(bare).
setCloneAllBranches(cloneAllBranches).
setCloneSubmodules(cloneSubModules).
setNoCheckout(noCheckout).
setDirectory(getDirectory());
setupCredentials(cloneCommand);
if (getProgressMonitor() != null) {
cloneCommand.setProgressMonitor(getProgressMonitor());
}
cloneCommand.call();
}
catch (Exception e) {
throw new GitBuildException(String.format(MESSAGE_CLONE_FAILED, getUri()), e);
}
}