當前位置: 首頁>>代碼示例>>Java>>正文


Java CloneCommand.setBranchesToClone方法代碼示例

本文整理匯總了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();
}
 
開發者ID:JordanMartinez,項目名稱:JGitFX,代碼行數:39,代碼來源:GitHelper.java

示例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);
        }
}
 
開發者ID:rimerosolutions,項目名稱:ant-git-tasks,代碼行數:33,代碼來源:CloneTask.java


注:本文中的org.eclipse.jgit.api.CloneCommand.setBranchesToClone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。