本文整理汇总了Java中org.eclipse.jgit.lib.TextProgressMonitor类的典型用法代码示例。如果您正苦于以下问题:Java TextProgressMonitor类的具体用法?Java TextProgressMonitor怎么用?Java TextProgressMonitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextProgressMonitor类属于org.eclipse.jgit.lib包,在下文中一共展示了TextProgressMonitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: to
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的package包/类
@Override
public void to(Path path) throws Git.Err {
LOG.info(() -> String.format("Cloning %s into %s...", url, path.toString()));
CloneCommand cloner = org.eclipse.jgit.api.Git.cloneRepository()
.setURI(url)
.setCredentialsProvider(new GitCredentialsProvider(
CredentialHandlers.handlerMap()
))
.setProgressMonitor(
enableOutput
? new TextProgressMonitor()
: NullProgressMonitor.INSTANCE
)
.setDirectory(path.toFile());
branchName.ifPresent(cloner::setBranch);
try {
cloner.call();
} catch (GitAPIException e) {
throw new Git.Err(url, path.toString(), e);
}
}
示例2: indexAll
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的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);
}
示例3: migrateData
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的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);
}
}
示例4: migrateData
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的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);
}
}
示例5: cloneRepository
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的package包/类
public void cloneRepository() throws Exception {
if (!passwordValidated) {
this.getPassword();
}
if (isCloned()) {
return;
}
ServerWizard2.LOGGER.info("Cloning " + this.remoteUrl + " into " + this.getRootDirectory().getAbsolutePath());
cloned = false;
try {
//TODO: determine MacOS hang issue with the progress monitor
//ProgressMonitor pim = new ProgressMonitor(null, "Cloning...", "", 0, 1);
//GitProgressMonitor gpim = new GitProgressMonitor(pim);
Git result = Git.cloneRepository()
.setCredentialsProvider(credentials)
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
.setURI(this.getRemoteUrl()).setDirectory(this.getRootDirectory()).call();
cloned = true;
result.close();
} catch (Exception e1) {
passwordValidated = false;
this.betterError(e1);
}
}
示例6: cloneRepo
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的package包/类
private static boolean cloneRepo(TargetCommit cloneCommit, String customCommit) {
CloneCommand cloneCommand = new CloneCommand()
.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)))
.setDirectory(new File(ROOT_DIR))
.setURI("https://github.com/SpongePowered/SpongeVanilla.git")
.setBranchesToClone(Collections.singleton("refs/heads/master"))
.setBranch("refs/heads/master")
.setCloneSubmodules(true);
try {
Git git = cloneCommand.call();
if (cloneCommit == TargetCommit.CUSTOM) {
git.checkout().setName(customCommit).call();
git.submoduleInit().call();
git.submoduleUpdate().setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out))).call();
}
return true;
} catch (GitAPIException e) {
e.printStackTrace();
}
return false;
}
示例7: gitClone
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的package包/类
/**
* Clone GIT repository from sourceforge.
*
* @param gitDirectory The directory of Git.
*/
private void gitClone(File gitDirectory) {
try {
git = Git.cloneRepository()
.setDirectory(gitDirectory)
.setURI("http://git.code.sf.net/p/neembuuuploader/gitcode")
.setProgressMonitor(new TextProgressMonitor()).call();
for (Ref f : git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call()) {
git.checkout().setName(f.getName()).call();
System.out.println("checked out branch " + f.getName()
+ ". HEAD: " + git.getRepository().getRef("HEAD"));
}
// try to checkout branches by specifying abbreviated names
git.checkout().setName("master").call();
} catch (GitAPIException | IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例8: gitClone
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的package包/类
/**
* Clone GIT repository from sourceforge.
*
* @param gitDirectory The directory of Git.
*/
private void gitClone(File gitDirectory) {
try {
git = Git.cloneRepository()
.setDirectory(gitDirectory)
.setURI(env.gitURI())
//.setURI("http://git.code.sf.net/p/neembuuuploader/gitcode")
.setProgressMonitor(new TextProgressMonitor()).call();
for (Ref f : git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call()) {
git.checkout().setName(f.getName()).call();
System.out.println("checked out branch " + f.getName()
+ ". HEAD: " + git.getRepository().getRef("HEAD"));
}
// try to checkout branches by specifying abbreviated names
git.checkout().setName("master").call();
} catch (GitAPIException | IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例9: gitMonitor
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的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 );
//
// }
// } ;
}
示例10: cloneNoCheckout
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的package包/类
/**
* In lieu of sparse checkout since it's not yet supported in JGit:
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=383772
*/
public void cloneNoCheckout(boolean withProgress) throws Exception {
CloneCommand clone = Git.cloneRepository().setURI(repositoryUrl).setDirectory(localRepo.getDirectory().getParentFile()).setNoCheckout(true);
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=442029
if (credentialsProvider != null)
clone.setCredentialsProvider(credentialsProvider);
if (withProgress)
clone.setProgressMonitor(new TextProgressMonitor(new PrintWriter(System.out)));
clone.call();
}
示例11: clone
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的package包/类
private Git clone(Pom pom, GitDependency dependency) throws MojoExecutionException {
final CloneCommand c = new CloneCommand();
final String location = dependency.getLocation();
c.setURI(location);
c.setCloneAllBranches(true);
c.setProgressMonitor(new TextProgressMonitor());
final GitDependencyHandler dependencyHandler = new GitDependencyHandler(dependency);
final String version = dependencyHandler.getDependencyVersion(pom);
final String tempDirectory = Directory.getTempDirectoryString(location, version);
c.setDirectory(new File(tempDirectory));
return c.call();
}
示例12: pushAll
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的package包/类
public void pushAll() throws GitAPIException {
git.push()
.setPushAll()
.setProgressMonitor(new TextProgressMonitor())
.setCredentialsProvider(new UsernamePasswordCredentialsProvider(GH_TOKEN, ""))
.call();
}
示例13: commitFileToBranch
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的package包/类
public void commitFileToBranch(String branch, String fileName, String content, String commitMessage)
throws IOException, GitAPIException {
final String beforeBranch = git.getRepository().getBranch();
final List<Ref> refList = git.branchList().call();
boolean exist = false;
for (Ref ref : refList) {
if (ref.getName().endsWith(branch)) {
exist = true;
break;
}
}
if (!exist) {
git.branchCreate().setName(branch).call();
}
git.checkout().setName(branch).call();
writeStringToFile(new File(gitRootDir, fileName), content);
git.add().addFilepattern(".").call();
git.commit().setAll(true).setMessage(commitMessage).call();
git.push()
.setPushAll()
.setProgressMonitor(new TextProgressMonitor())
.setCredentialsProvider(new UsernamePasswordCredentialsProvider(GH_TOKEN, ""))
.call();
git.checkout().setName(beforeBranch).call();
await().pollInterval(3, SECONDS)
.timeout(120, SECONDS)
.until(ghBranchAppeared(getGhRepo(), branch));
}
示例14: run
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的package包/类
@Override
public int run() throws Exception {
mustHaveValidSite();
Injector dbInjector = createDbInjector(SINGLE_USER);
manager.add(dbInjector);
manager.start();
RuntimeShutdown.add(manager::stop);
dbInjector.injectMembers(this);
ProgressMonitor progress = new TextProgressMonitor();
progress.beginTask("Importing entities", ProgressMonitor.UNKNOWN);
try (ReviewDb db = schemaFactory.open()) {
for (RelationModel model : new JavaSchemaModel(ReviewDb.class).getRelations()) {
relations.put(model.getRelationID(), Relation.create(model, db));
}
Parser<UnknownFieldSet> parser = UnknownFieldSet.getDefaultInstance().getParserForType();
try (InputStream in = new BufferedInputStream(Files.newInputStream(file.toPath()))) {
UnknownFieldSet msg;
while ((msg = parser.parseDelimitedFrom(in)) != null) {
Map.Entry<Integer, UnknownFieldSet.Field> e =
Iterables.getOnlyElement(msg.asMap().entrySet());
Relation rel =
checkNotNull(
relations.get(e.getKey()),
"unknown relation ID %s in message: %s",
e.getKey(),
msg);
List<ByteString> values = e.getValue().getLengthDelimitedList();
checkState(values.size() == 1, "expected one string field in message: %s", msg);
upsert(rel, values.get(0));
progress.update(1);
}
}
progress.endTask();
}
return 0;
}
示例15: indexAll
import org.eclipse.jgit.lib.TextProgressMonitor; //导入依赖的package包/类
@Override
public SiteIndexer.Result indexAll(final ProjectIndex index) {
ProgressMonitor progress = new TextProgressMonitor(new PrintWriter(progressOut));
progress.start(2);
List<Project.NameKey> names = collectProjects(progress);
return reindexProjects(index, names, progress);
}