当前位置: 首页>>代码示例>>Java>>正文


Java ProgressMonitor类代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.ProgressMonitor的典型用法代码示例。如果您正苦于以下问题:Java ProgressMonitor类的具体用法?Java ProgressMonitor怎么用?Java ProgressMonitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProgressMonitor类属于org.eclipse.jgit.lib包,在下文中一共展示了ProgressMonitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clone

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
@Override
public File clone(String branch, Set<String> checkoutFiles, ProgressMonitor monitor) throws GitException {
    checkGitUrl();

    File gitDir = getGitPath().toFile();

    // delete existing git folder since may have conflict
    if (gitDir.exists()) {
        try {
            FileUtils.delete(gitDir.getParentFile(), FileUtils.RECURSIVE);
        } catch (IOException e) {
            // IO error on delete existing folder
        }
    }

    // git init
    initGit(checkoutFiles);

    pull(branch, monitor);
    return gitDir;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:22,代码来源:JGitBasedClient.java

示例2: cloneRepo

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的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

示例3: indexAll

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
@Override
public Result indexAll(ChangeIndex index) {
  ProgressMonitor pm = new TextProgressMonitor();
  pm.beginTask("Collecting projects", ProgressMonitor.UNKNOWN);
  SortedSet<ProjectHolder> projects = new TreeSet<>();
  int changeCount = 0;
  Stopwatch sw = Stopwatch.createStarted();
  for (Project.NameKey name : projectCache.all()) {
    try (Repository repo = repoManager.openRepository(name)) {
      long size = estimateSize(repo);
      changeCount += size;
      projects.add(new ProjectHolder(name, size));
    } catch (IOException e) {
      log.error("Error collecting projects", e);
      return new Result(sw, false, 0, 0);
    }
    pm.update(1);
  }
  pm.endTask();
  setTotalWork(changeCount);

  return indexAll(index, projects);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:AllChangesIndexer.java

示例4: migrateData

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
  try {
    try (Repository repo = repoManager.openRepository(allUsersName)) {
      ProgressMonitor pm = new TextProgressMonitor();
      pm.beginTask("Collecting accounts", ProgressMonitor.UNKNOWN);
      Set<Account> accounts = scanAccounts(db, pm);
      pm.endTask();
      pm.beginTask("Migrating accounts to NoteDb", accounts.size());
      for (Account account : accounts) {
        updateAccountInNoteDb(repo, account);
        pm.update(1);
      }
      pm.endTask();
    }
  } catch (IOException | ConfigInvalidException e) {
    throw new OrmException("Migrating accounts to NoteDb failed", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:Schema_154.java

示例5: scanAccounts

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
private Set<Account> scanAccounts(ReviewDb db, ProgressMonitor pm) throws SQLException {
  try (Statement stmt = newStatement(db);
      ResultSet rs =
          stmt.executeQuery(
              "SELECT account_id,"
                  + " registered_on,"
                  + " full_name, "
                  + " preferred_email,"
                  + " status,"
                  + " inactive"
                  + " FROM accounts")) {
    Set<Account> s = new HashSet<>();
    while (rs.next()) {
      Account a = new Account(new Account.Id(rs.getInt(1)), rs.getTimestamp(2));
      a.setFullName(rs.getString(3));
      a.setPreferredEmail(rs.getString(4));
      a.setStatus(rs.getString(5));
      a.setActive(rs.getString(6).equals("N"));
      s.add(a);
      pm.update(1);
    }
    return s;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:Schema_154.java

示例6: migrateData

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
  try {
    try (Repository repo = repoManager.openRepository(allUsersName)) {
      ProgressMonitor pm = new TextProgressMonitor();
      pm.beginTask("Removing \"My Drafts\" menu items", ProgressMonitor.UNKNOWN);
      for (Account.Id id : (Iterable<Account.Id>) Accounts.readUserRefs(repo)::iterator) {
        if (removeMyDrafts(repo, id)) {
          pm.update(1);
        }
      }
      pm.endTask();
    }
  } catch (IOException | ConfigInvalidException e) {
    throw new OrmException("Removing \"My Drafts\" menu items failed", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:Schema_160.java

示例7: doImport

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
@Override
public void doImport(ProgressMonitor progress)
    throws GitCloneFailedException, GitDestinationAlreadyExistsException,
        GitDestinationNotWritableException {
  CloneCommand clone = new CloneCommand();
  clone.setCredentialsProvider(getRepository().getCredentialsProvider());
  String sourceUri = getSourceUri();
  clone.setURI(sourceUri);
  clone.setBare(true);
  clone.setDirectory(destinationDirectory);
  if (progress != null) {
    clone.setProgressMonitor(progress);
  }
  try {
    LOG.info(sourceUri + "| Clone into " + destinationDirectory);
    clone.call();
  } catch (Throwable e) {
    throw new GitCloneFailedException(sourceUri, e);
  }
}
 
开发者ID:GerritCodeReview,项目名称:plugins_github,代码行数:21,代码来源:GitCloneStep.java

示例8: doImport

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
@Override
public void doImport(ProgressMonitor progress) throws Exception {
  MetaDataUpdate md = null;
  try {
    md = metaDataUpdateFactory.create(getProjectNameKey());
    projectConfig = ProjectConfig.read(md);
    progress.beginTask("Configure Gerrit project", 2);
    setProjectSettings();
    progress.update(1);
    setProjectPermissions();
    progress.update(1);
    md.setMessage("Imported from " + getSourceUri());
    projectConfig.commit(md);
    projectCache.onCreateProject(getProjectNameKey());
  } finally {
    if (md != null) {
      md.close();
    }
    progress.endTask();
  }
}
 
开发者ID:GerritCodeReview,项目名称:plugins_github,代码行数:22,代码来源:CreateProjectStep.java

示例9: createNewRepo

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
private void createNewRepo(ProgressMonitor monitor) throws GitAPIException, IllegalArgumentException {
    File localRepo = new File(localPath);
    if (localRepo.exists()) // Safety check so we don't accidentally delete directory
        throw new IllegalStateException("Directory already exists");

    try {
        CloneCommand cloneCommand = Git.cloneRepository()
                .setCredentialsProvider(credentialsProvider)
                .setURI(remotePath)
                .setBranch(branch)
                .setDirectory(localRepo)
                .setBare(false);
        if (monitor != null)
            cloneCommand.setProgressMonitor(monitor);
        cloneCommand.call();
    } catch (GitAPIException e) {
        FileUtils.deleteDirectory(localRepo);
        throw e;
    }
}
 
开发者ID:hdweiss,项目名称:mOrgAnd,代码行数:21,代码来源:JGitWrapper.java

示例10: gitMonitor

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
private ProgressMonitor gitMonitor ( Writer w ) {
	return new TextProgressMonitor( w ) {

	};
	// return new ProgressMonitor() {
	//
	// @Override
	// public void update ( int completed ) {
	// // TODO Auto-generated method stub
	// logger.info( "items completed: {}", completed );
	// }
	//
	// @Override
	// public void start ( int totalTasks ) {
	// // TODO Auto-generated method stub
	//
	// }
	//
	// @Override
	// public boolean isCancelled () {
	// // TODO Auto-generated method stub
	// return false;
	// }
	//
	// @Override
	// public void endTask () {
	// // TODO Auto-generated method stub
	//
	// }
	//
	// @Override
	// public void beginTask ( String title, int totalWork ) {
	// // TODO Auto-generated method stub
	// logger.info( "progress: {}, items remaining: {}", title, totalWork );
	//
	// }
	// } ;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:39,代码来源:SourceControlManager.java

示例11: fetch

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
@Override
public String fetch(String branch, String filePath, ProgressMonitor monitor) throws GitException {
    checkProject();

    try {
        GitlabRepositoryFile file = connect.getRepositoryFile(project, filePath, branch);
        String base64Content = file.getContent();
        byte[] contentBytes = Base64.getDecoder().decode(base64Content);
        return new String(contentBytes, "UTF-8");
    } catch (IOException e) {
        return null;
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:14,代码来源:GitLabClient.java

示例12: fetch

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
@Override
public String fetch(String branch, String filePath, ProgressMonitor monitor) throws GitException {
    clone(branch, Sets.newHashSet(filePath), monitor);
    Path targetPath = Paths.get(targetDir.toString(), filePath);

    if (Files.exists(targetPath)) {
        try {
            return com.google.common.io.Files.toString(targetPath.toFile(), Charset.forName("UTF-8"));
        } catch (IOException e) {
            return null;
        }
    }

    return null;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:16,代码来源:JGitBasedClient.java

示例13: pull

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
@Override
public void pull(String branch, ProgressMonitor monitor) throws GitException {
    try (Git git = gitOpen()) {
        PullCommand pullCommand = pullCommand(branch, git);
        if (monitor != null) {
            pullCommand.setProgressMonitor(monitor);
        } else {
            pullCommand.setProgressMonitor(new DebugProgressMonitor());
        }
        pullCommand.call();
    } catch (Throwable e) {
        throw new GitException("Fail to pull with specific files: " + ExceptionUtil.findRootCause(e).getMessage());
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:15,代码来源:JGitBasedClient.java

示例14: setupMergeCommand

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
private static void setupMergeCommand(MergeCommand merge, List<Ref> commitsByRef, List<AnyObjectId> commitsById,
                                      List<NamedCommit> commitsByNameAndId, ProgressMonitor monitor,
                                      MergeStrategy strategy, MergeCommand.FastForwardMode fastForwardMode) {
    commitsByRef.forEach(merge::include);
    commitsById.forEach(merge::include);
    commitsByNameAndId.forEach(nc -> merge.include(nc.getName(), nc.getObjectId()));

    if (monitor != null) { merge.setProgressMonitor(monitor); }

    merge
            .setFastForward(fastForwardMode)
            .setStrategy(strategy);
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:14,代码来源:GitHelper.java

示例15: mergeWithSquash

import org.eclipse.jgit.lib.ProgressMonitor; //导入依赖的package包/类
public static MergeResult mergeWithSquash(Git git, MergeStrategy strategy,  List<Ref> commitsByRef,
                                   List<AnyObjectId> commitsById, List<NamedCommit> commitsByNameAndId,
                                   MergeCommand.FastForwardMode fastForwardMode,
                                   ProgressMonitor monitor) throws GitAPIException {
    MergeCommand merge = git.merge();

    setupMergeCommand(merge, commitsByRef, commitsById, commitsByNameAndId, monitor, strategy, fastForwardMode);

    return merge
            .setStrategy(strategy)
            .setFastForward(fastForwardMode)
            .setSquash(true)
            .call();
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:15,代码来源:GitHelper.java


注:本文中的org.eclipse.jgit.lib.ProgressMonitor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。