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


Java FileMode.TREE属性代码示例

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


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

示例1: checkProps

private void checkProps(@NotNull GitProperty[] gitProperties, @Nullable String local, @Nullable String global, @Nullable String mine, @NotNull FileMode fileMode, @NotNull String... path) {
  GitProperty[] props = gitProperties;
  for (int i = 0; i < path.length; ++i) {
    final String name = path[i];
    final FileMode mode = i == path.length - 1 ? fileMode : FileMode.TREE;
    props = createForChild(props, name, mode);
  }
  final Map<String, String> text = new HashMap<>();
  for (GitProperty prop : props) {
    prop.apply(text);
  }
  Assert.assertEquals(text.remove("svn:eol-style"), local);
  Assert.assertEquals(text.remove("svn:auto-props"), global);
  Assert.assertEquals(text.remove("svn:mime-type"), mine);
  Assert.assertTrue(text.isEmpty(), text.toString());
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:16,代码来源:GitEolTest.java

示例2: streamFromRepo

protected boolean streamFromRepo(HttpServletRequest request, HttpServletResponse response, Repository repository, RevCommit commit,
		String requestedPath) throws IOException {

	boolean served = false;
	RevWalk rw = new RevWalk(repository);
	TreeWalk tw = new TreeWalk(repository);
	try {
		tw.reset();
		tw.addTree(commit.getTree());
		PathFilter f = PathFilter.create(requestedPath);
		tw.setFilter(f);
		tw.setRecursive(true);
		MutableObjectId id = new MutableObjectId();
		ObjectReader reader = tw.getObjectReader();
		while (tw.next()) {
			FileMode mode = tw.getFileMode(0);
			if (mode == FileMode.GITLINK || mode == FileMode.TREE) {
				continue;
			}
			tw.getObjectId(id, 0);

			String filename = StringUtils.getLastPathElement(requestedPath);
			try {
				String userAgent = request.getHeader("User-Agent");
				if (userAgent != null && userAgent.indexOf("MSIE 5.5") > -1) {
					response.setHeader("Content-Disposition", "filename=\"" + URLEncoder.encode(filename, Constants.ENCODING) + "\"");
				} else if (userAgent != null && userAgent.indexOf("MSIE") > -1) {
					response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(filename, Constants.ENCODING) + "\"");
				} else {
					response.setHeader("Content-Disposition", "attachment; filename=\""
							+ new String(filename.getBytes(Constants.ENCODING), "latin1") + "\"");
				}
			} catch (UnsupportedEncodingException e) {
				response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
			}

			long len = reader.getObjectSize(id, org.eclipse.jgit.lib.Constants.OBJ_BLOB);
			setContentType(response, "application/octet-stream");
			response.setIntHeader("Content-Length", (int) len);
			ObjectLoader ldr = repository.open(id);
			ldr.copyTo(response.getOutputStream());
			served = true;
		}
	} finally {
		tw.close();
		rw.dispose();
	}

	response.flushBuffer();
	return served;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:51,代码来源:RawServlet.java

示例3: zip

/**
 * Zips the contents of the tree at the (optionally) specified revision and the (optionally) specified basepath to the supplied outputstream.
 * 
 * @param repository
 * @param basePath
 *            if unspecified, entire repository is assumed.
 * @param objectId
 *            if unspecified, HEAD is assumed.
 * @param os
 * @return true if repository was successfully zipped to supplied output stream
 */
public static boolean zip(Repository repository, String basePath, String objectId, OutputStream os) {
	RevCommit commit = JGitUtils.getCommit(repository, objectId);
	if (commit == null) {
		return false;
	}
	boolean success = false;
	RevWalk rw = new RevWalk(repository);
	TreeWalk tw = new TreeWalk(repository);
	try {
		tw.reset();
		tw.addTree(commit.getTree());
		ZipArchiveOutputStream zos = new ZipArchiveOutputStream(os);
		zos.setComment("Generated by Gitblit");
		if (!StringUtils.isEmpty(basePath)) {
			PathFilter f = PathFilter.create(basePath);
			tw.setFilter(f);
		}
		tw.setRecursive(true);
		MutableObjectId id = new MutableObjectId();
		ObjectReader reader = tw.getObjectReader();
		long modified = commit.getAuthorIdent().getWhen().getTime();
		while (tw.next()) {
			FileMode mode = tw.getFileMode(0);
			if (mode == FileMode.GITLINK || mode == FileMode.TREE) {
				continue;
			}
			tw.getObjectId(id, 0);

			ZipArchiveEntry entry = new ZipArchiveEntry(tw.getPathString());
			entry.setSize(reader.getObjectSize(id, Constants.OBJ_BLOB));
			entry.setComment(commit.getName());
			entry.setUnixMode(mode.getBits());
			entry.setTime(modified);
			zos.putArchiveEntry(entry);

			ObjectLoader ldr = repository.open(id);
			ldr.copyTo(zos);
			zos.closeArchiveEntry();
		}
		zos.finish();
		success = true;
	} catch (IOException e) {
		error(e, repository, "{0} failed to zip files from commit {1}", commit.getName());
	} finally {
		tw.close();
		rw.close();
		rw.dispose();
	}
	return success;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:61,代码来源:CompressionUtils.java

示例4: GitFileEmptyTree

GitFileEmptyTree(@NotNull GitRepository repo, @NotNull String parentPath, int revision) {
  super(PropertyMapping.getRootProperties(), parentPath, GitProperty.emptyArray, "", FileMode.TREE);
  this.repo = repo;
  this.revision = revision;
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:5,代码来源:GitFileEmptyTree.java

示例5: getFileMode

@NotNull
public FileMode getFileMode() {
  return FileMode.TREE;
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:4,代码来源:GitFileEmptyTree.java

示例6: createChild

@NotNull
@Override
public GitEntry createChild(@NotNull String name, boolean isDir) {
  return new GitEntryImpl(props, getFullPath(), GitProperty.emptyArray, name, isDir ? FileMode.TREE : FileMode.REGULAR_FILE);
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:5,代码来源:GitEntryImpl.java

示例7: createChild

@NotNull
@Override
default GitEntry createChild(@NotNull String name, boolean isDir) {
  return new GitEntryImpl(getRawProperties(), getFullPath(), GitProperty.emptyArray, name, isDir ? FileMode.TREE : FileMode.REGULAR_FILE);
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:5,代码来源:GitFile.java

示例8: getFilesInVersion

/**
 * Returns a list containing the paths to all files in the specified
 * version.
 *
 * @param c version identifier (commit)
 * @return a list containing the paths to all files in the specified version
 * @throws IllegalStateException if this file is currently not open
 */
private Collection<String> getFilesInVersion(RevCommit c) {

    Collection<String> result = new ArrayList<String>();

    // file has to be opened
    if (!isOpened()) {
        throw new IllegalStateException(
                "File\"" + getFile().getPath() + "\" not opened!");
    }

    Git git = null;

    try {
        git = Git.open(tmpFolder);
        // create a tree walk to search for files
        TreeWalk walk = new TreeWalk(git.getRepository());
        if (walk != null) {

            // recursively search fo files
            walk.setRecursive(true);
            // add the tree the specified commit belongs to
            walk.addTree(c.getTree());

            // walk through the tree
            while (walk.next()) {

                // TODO: is it a problem if mode is treemode?
                final FileMode mode = walk.getFileMode(0);
                if (mode == FileMode.TREE) {
                    System.out.print(
                            "VersionedFile."
                            + "getFilesInVersion(): FileMode unexpected!");
                }

                // retrieve the path name of the current element
                String fileName = walk.getPathString();

                // we do not want to commit/checkout this file
                if (!fileName.equals(FILE_INFO_NAME)) {
                    result.add(walk.getPathString());
                }
            }
        }

    } catch (IOException ex) {
        closeGit(git);
        Logger.getLogger(VersionedFile.class.getName()).
                log(Level.SEVERE, null, ex);
    }

    closeGit(git);

    return result;

}
 
开发者ID:miho,项目名称:VGitArchive,代码行数:63,代码来源:VersionedFile.java

示例9: zip

/**
 * Zips the contents of the tree at the (optionally) specified revision and
 * the (optionally) specified basepath to the supplied outputstream.
 * 
 * @param repository
 * @param basePath
 *            if unspecified, entire repository is assumed.
 * @param objectId
 *            if unspecified, HEAD is assumed.
 * @param os
 * @return true if repository was successfully zipped to supplied output
 *         stream
 */
public static boolean zip(Repository repository, String basePath, String objectId,
		OutputStream os) {
	RevCommit commit = JGitUtils.getCommit(repository, objectId);
	if (commit == null) {
		return false;
	}
	boolean success = false;
	RevWalk rw = new RevWalk(repository);
	TreeWalk tw = new TreeWalk(repository);
	try {
		tw.reset();
		tw.addTree(commit.getTree());
		ZipArchiveOutputStream zos = new ZipArchiveOutputStream(os);
		zos.setComment("Generated by Gitblit");
		if (!StringUtils.isEmpty(basePath)) {
			PathFilter f = PathFilter.create(basePath);
			tw.setFilter(f);
		}
		tw.setRecursive(true);
		MutableObjectId id = new MutableObjectId();
		ObjectReader reader = tw.getObjectReader();
		long modified = commit.getAuthorIdent().getWhen().getTime();
		while (tw.next()) {
			FileMode mode = tw.getFileMode(0);
			if (mode == FileMode.GITLINK || mode == FileMode.TREE) {
				continue;
			}
			tw.getObjectId(id, 0);

			ZipArchiveEntry entry = new ZipArchiveEntry(tw.getPathString());
			entry.setSize(reader.getObjectSize(id, Constants.OBJ_BLOB));
			entry.setComment(commit.getName());
			entry.setUnixMode(mode.getBits());
			entry.setTime(modified);
			zos.putArchiveEntry(entry);

			ObjectLoader ldr = repository.open(id);
			ldr.copyTo(zos);
			zos.closeArchiveEntry();
		}
		zos.finish();
		success = true;
	} catch (IOException e) {
		error(e, repository, "{0} failed to zip files from commit {1}", commit.getName());
	} finally {
		tw.release();
		rw.dispose();
	}
	return success;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:63,代码来源:CompressionUtils.java

示例10: createForPath

@NotNull
private static GitProperty[] createForPath(@NotNull GitProperty[] baseProps, @NotNull String path) {
  GitProperty[] props = baseProps;
  String[] pathItems = path.split("/");
  for (int i = 0; i < pathItems.length; ++i) {
    final String name = pathItems[i];
    if (!name.isEmpty()) {
      final FileMode mode = i == pathItems.length - 1 ? FileMode.REGULAR_FILE : FileMode.TREE;
      props = createForChild(props, name, mode);
    }
  }
  return props;
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:13,代码来源:GitEolTest.java

示例11: getOnlyChildSubtree

private CanonicalTreeParser getOnlyChildSubtree(RevWalk rw, ObjectId id, byte[] prefix)
    throws IOException {
  CanonicalTreeParser p = new CanonicalTreeParser(prefix, rw.getObjectReader(), id);
  if (p.eof() || p.getEntryFileMode() != FileMode.TREE) {
    return null;
  }
  p.next(1);
  return p.eof() ? p : null;
}
 
开发者ID:afrojer,项目名称:gitiles,代码行数:9,代码来源:PathServlet.java


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