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


Java ObjectLoader类代码示例

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


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

示例1: putEntry

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
@Override
public void putEntry(ZipOutputStream out, ObjectId tree, String path, FileMode mode, ObjectLoader loader) throws IOException {
    // loader is null for directories...
    if (loader != null) {
        ZipEntry entry = new ZipEntry(path);

        if (tree instanceof RevCommit) {
            long t = ((RevCommit) tree).getCommitTime() * 1000L;
            entry.setTime(t);
        }

        out.putNextEntry(entry);
        out.write(loader.getBytes());
        out.closeEntry();
    }
}
 
开发者ID:centic9,项目名称:jgit-cookbook,代码行数:17,代码来源:CreateCustomFormatArchive.java

示例2: getLoaderFrom

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
/**
 * Gets the loader for a file from a specified commit and its path
 * 
 * @param commit
 *          - the commit from which to get the loader
 * @param path
 *          - the path to the file
 * @return the loader
 * @throws MissingObjectException
 * @throws IncorrectObjectTypeException
 * @throws CorruptObjectException
 * @throws IOException
 */
public ObjectLoader getLoaderFrom(ObjectId commit, String path)
		throws IOException {
	Repository repository = git.getRepository();
	RevWalk revWalk = new RevWalk(repository);
	RevCommit revCommit = revWalk.parseCommit(commit);
	// and using commit's tree find the path
	RevTree tree = revCommit.getTree();
	TreeWalk treeWalk = new TreeWalk(repository);
	treeWalk.addTree(tree);
	treeWalk.setRecursive(true);
	treeWalk.setFilter(PathFilter.create(path));

	ObjectLoader loader = null;
	if (treeWalk.next()) {
		ObjectId objectId = treeWalk.getObjectId(0);
		loader = repository.open(objectId);
	}

	treeWalk.close();
	revWalk.close();
	return loader;
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:36,代码来源:GitAccess.java

示例3: getProjectList

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
public List<String> getProjectList(String projectName){
	 FileRepositoryBuilder builder = new FileRepositoryBuilder();
	
	List list= new ArrayList();
       try {
       	log.debug("errororororoor123 "+ "\n");
       	Repository repository = builder
		        .readEnvironment() // scan environment GIT_* variables
		        .setGitDir(new File("C:/test0101/" + projectName +"/.git")) // scan up the file system tree
		        .build();
       	DirCache index = DirCache.read(repository);
       	 ObjectLoader loader = null;
       	log.debug("DirCache has " + index.getEntryCount() + " items");
             for (int i = 0; i < index.getEntryCount(); i++) {
             	log.debug(index.getEntry(i).getPathString()+ "\n");
             	list.add(index.getEntry(i).getPathString());
            
             }
	} catch (IOException e) {
		log.debug("errororororoor "+ "\n");
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return list;
       
}
 
开发者ID:LandvibeDev,项目名称:codefolio,代码行数:27,代码来源:GitUtils.java

示例4: getRevisionGitNotes

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
/**
 * Storing revisions in Git Notes causes object hash computation, which is expensive.
 */
public AssetRevision getRevisionGitNotes(File file) throws IOException {
    AssetRevision rev = file2rev.get(file);
    if (rev == null) {
        ObjectId workingId = getObjectId(file);

        try (RevWalk walk = new RevWalk(localRepo)) {
            Ref ref = localRepo.findRef(NOTES_REF);
            if (ref != null) {
                RevCommit notesCommit = walk.parseCommit(ref.getObjectId());
                NoteMap notes = NoteMap.read(walk.getObjectReader(), notesCommit);
                Note note = notes.getNote(workingId);
                if (note != null) {
                    ObjectLoader loader = localRepo.open(note.getData());
                    String noteStr = new String(loader.getBytes()).trim();
                    rev = parseAssetRevision(noteStr);
                    file2rev.put(file, rev);
                    return rev;
                }
            }
        }
    }

    return rev;
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:28,代码来源:VersionControlGit.java

示例5: readFromCommit

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
public byte[] readFromCommit(String commitId, String path) throws Exception {
    try (RevWalk revWalk = new RevWalk(localRepo)) {
        RevCommit commit = revWalk.parseCommit(ObjectId.fromString(commitId));
        // use commit's tree find the path
        RevTree tree = commit.getTree();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try (TreeWalk treeWalk = new TreeWalk(localRepo)) {
            treeWalk.addTree(tree);
            treeWalk.setRecursive(true);
            treeWalk.setFilter(PathFilter.create(path));
            if (!treeWalk.next()) {
                return null;
            }

            ObjectId objectId = treeWalk.getObjectId(0);
            ObjectLoader loader = localRepo.open(objectId);

            loader.copyTo(baos);
        }
        revWalk.dispose();
        return baos.toByteArray();
    }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:24,代码来源:VersionControlGit.java

示例6: getFileFromCommit

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
public static boolean getFileFromCommit(final OutputStream os, final String file, final Repository repo, final RevTree tree) throws IOException, GitAPIException {
    final TreeWalk treeWalk = new TreeWalk(repo);
    treeWalk.addTree(tree);
    treeWalk.setRecursive(true);
    treeWalk.setFilter(PathFilter.create(file));
    if (!treeWalk.next()) {
        logger.info("Did not find expected file '" + file + "'");
        return false;
    }

    final ObjectId objectId = treeWalk.getObjectId(0);
    final ObjectLoader loader = repo.open(objectId);

    // and then one can the loader to read the file
    loader.copyTo(os);
    return true;
}
 
开发者ID:cobr123,项目名称:VirtaMarketAnalyzer,代码行数:18,代码来源:GitHubPublisher.java

示例7: merge

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
@Override
public Note merge(Note base, Note ours, Note theirs, ObjectReader reader, ObjectInserter inserter)
    throws IOException {
  if (ours == null) {
    return theirs;
  }
  if (theirs == null) {
    return ours;
  }
  if (ours.getData().equals(theirs.getData())) {
    return ours;
  }

  ObjectLoader lo = reader.open(ours.getData());
  byte[] sep = new byte[] {'\n'};
  ObjectLoader lt = reader.open(theirs.getData());
  try (ObjectStream os = lo.openStream();
      ByteArrayInputStream b = new ByteArrayInputStream(sep);
      ObjectStream ts = lt.openStream();
      UnionInputStream union = new UnionInputStream(os, b, ts)) {
    ObjectId noteData =
        inserter.insert(Constants.OBJ_BLOB, lo.getSize() + sep.length + lt.getSize(), union);
    return new Note(ours, noteData);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:ReviewNoteMerger.java

示例8: zipBlob

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
@SuppressWarnings("resource")
private BinaryResult zipBlob(
    final String path, ObjectLoader obj, RevCommit commit, @Nullable final String suffix) {
  final String commitName = commit.getName();
  final long when = commit.getCommitTime() * 1000L;
  return new BinaryResult() {
    @Override
    public void writeTo(OutputStream os) throws IOException {
      try (ZipOutputStream zipOut = new ZipOutputStream(os)) {
        String decoration = randSuffix();
        if (!Strings.isNullOrEmpty(suffix)) {
          decoration = suffix + '-' + decoration;
        }
        ZipEntry e = new ZipEntry(safeFileName(path, decoration));
        e.setComment(commitName + ":" + path);
        e.setSize(obj.getSize());
        e.setTime(when);
        zipOut.putNextEntry(e);
        obj.copyTo(zipOut);
        zipOut.closeEntry();
      }
    }
  }.setContentType(ZIP_TYPE).setAttachmentName(safeFileName(path, suffix) + ".zip").disableGzip();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:25,代码来源:FileContentUtil.java

示例9: execute

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
public Ref execute() {
    try {
        final Ref value = repo.getRefDatabase().getRef(name);
        if (value != null) {
            return value;
        }
        final ObjectId treeRef = repo.resolve(name + "^{tree}");
        if (treeRef != null) {
            final ObjectLoader loader = repo.getObjectDatabase().newReader().open(treeRef);
            if (loader.getType() == OBJ_TREE) {
                return new ObjectIdRef.PeeledTag(Ref.Storage.NEW,
                                                 name,
                                                 ObjectId.fromString(name),
                                                 treeRef);
            }
        }
    } catch (final Exception ignored) {
    }
    return null;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:21,代码来源:GetRef.java

示例10: parseBlobs

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
private void parseBlobs(String repositoryPath, String syntaxTreeDirPath) {
  File repoDir = new File(repositoryPath);
  try {
    Repository repo = new FileRepository(repoDir);

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line;
    while ( (line = br.readLine()) != null) {
      root = new Tree("");

      ObjectId obj = ObjectId.fromString(line);
      ObjectLoader loader = repo.open(obj);

      char[] src = IOUtils.toCharArray(loader.openStream());
      File outputFile = new File(syntaxTreeDirPath, line);
      parseSourcecodeAndWriteSyntaxTree(src, outputFile);
    }
  } catch (IOException e) {
    e.printStackTrace();
  }

}
 
开发者ID:niyaton,项目名称:kenja-java-parser,代码行数:23,代码来源:GitTreeCreator.java

示例11: open

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
private byte[] open(ObjectReader reader, FileMode mode,
                    AbbreviatedObjectId id) throws IOException {
    if (mode == FileMode.MISSING)
        return new byte[] { };

    if (mode.getObjectType() != Constants.OBJ_BLOB)
        return new byte[] { };

    if (!id.isComplete()) {
        Collection<ObjectId> ids = reader.resolve(id);
        if (ids.size() == 1)
            id = AbbreviatedObjectId.fromObjectId(ids.iterator().next());
        else if (ids.size() == 0)
            throw new MissingObjectException(id, Constants.OBJ_BLOB);
        else
            throw new AmbiguousObjectException(id, ids);
    }

    ObjectLoader ldr = reader.open(id.toObjectId());
    return ldr.getCachedBytes(bigFileThreshold);
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:22,代码来源:LineContextDiffer.java

示例12: extractPackage

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
private void extractPackage(Repository _repo) throws MissingObjectException, IOException{
	ObjectLoader newFile = _repo.open(this.newObjId);
	String newData = readStream(newFile.openStream());

	
	ASTParser parser = ASTParser.newParser(AST.JLS3);
	parser.setSource(newData.toCharArray());
	parser.setKind(ASTParser.K_COMPILATION_UNIT);
	Hashtable<String, String> options = JavaCore.getOptions();
	options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.DISABLED);
	parser.setCompilerOptions(options);
	
	final CompilationUnit cu = (CompilationUnit) parser.createAST(null);

	cu.accept(new ASTVisitor() {
		
		public boolean visit(PackageDeclaration _package){
			packageName = _package.getName().getFullyQualifiedName();
			return false;
		}
	});
}
 
开发者ID:gems-uff,项目名称:dominoes,代码行数:23,代码来源:FileNode.java

示例13: getByteContent

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
/**
 * Retrieves the raw byte content of a file in the specified tree.
 * 
 * @param repository
 * @param tree
 *            if null, the RevTree from HEAD is assumed.
 * @param path
 * @return content as a byte []
 */
public static byte[] getByteContent(Repository repository, RevTree tree, final String path, boolean throwError) {
	RevWalk rw = new RevWalk(repository);
	byte[] content = null;
	try (TreeWalk tw = new TreeWalk(repository)) {
		tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));
		if (tree == null) {
			ObjectId object = getDefaultBranch(repository);
			if (object == null) {
				return null;
			}
			RevCommit commit = rw.parseCommit(object);
			tree = commit.getTree();
		}
		tw.reset(tree);
		while (tw.next()) {
			if (tw.isSubtree() && !path.equals(tw.getPathString())) {
				tw.enterSubtree();
				continue;
			}
			ObjectId entid = tw.getObjectId(0);
			FileMode entmode = tw.getFileMode(0);
			if (entmode != FileMode.GITLINK) {
				ObjectLoader ldr = repository.open(entid, Constants.OBJ_BLOB);
				content = ldr.getCachedBytes();
			}
		}
	} catch (Throwable t) {
		if (throwError) {
			error(t, repository, "{0} can't find {1} in tree {2}", path, tree.name());
		}
	} finally {
		rw.close();
		rw.dispose();
	}
	return content;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:46,代码来源:JGitUtils.java

示例14: getMd5

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
@NotNull
@Override
public String getMd5(@NotNull GitObject<? extends ObjectId> objectId) throws IOException, SVNException {
  final ObjectLoader loader = objectId.openObject();
  final ObjectStream stream = loader.openStream();
  final byte[] header = new byte[Constants.POINTER_MAX_SIZE];
  int length = ByteStreams.read(stream, header, 0, header.length);
  if (length < header.length) {
    final Map<String, String> pointer = Pointer.parsePointer(header, 0, length);
    if (pointer != null) {
      String md5 = getReader(pointer).getMd5();
      if (md5 != null) {
        return md5;
      }
    }
  }
  return GitFilterHelper.getMd5(this, cacheMd5, null, objectId);
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:19,代码来源:LfsFilter.java

示例15: getByteContent

import org.eclipse.jgit.lib.ObjectLoader; //导入依赖的package包/类
/**
 * Gets the raw byte content of the specified blob object.
 * 
 * @param repository
 * @param objectId
 * @return byte [] blob content
 */
public static byte[] getByteContent(Repository repository, String objectId) {
	RevWalk rw = new RevWalk(repository);
	byte[] content = null;
	try {
		RevBlob blob = rw.lookupBlob(ObjectId.fromString(objectId));
		rw.parseBody(blob);
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		ObjectLoader ldr = repository.open(blob.getId(), Constants.OBJ_BLOB);
		byte[] tmp = new byte[4096];
		InputStream in = ldr.openStream();
		int n;
		while ((n = in.read(tmp)) > 0) {
			os.write(tmp, 0, n);
		}
		in.close();
		content = os.toByteArray();
	} catch (Throwable t) {
		error(t, repository, "{0} can't find blob {1}", objectId);
	} finally {
		rw.dispose();
	}
	return content;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:31,代码来源:JGitUtils.java


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