本文整理了Java中org.eclipse.jgit.util.FS.resolve()
方法的一些代码示例,展示了FS.resolve()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FS.resolve()
方法的具体详情如下:
包路径:org.eclipse.jgit.util.FS
类名称:FS
方法名:resolve
[英]Resolve this file to its actual path name that the JRE can use.
This method can be relatively expensive. Computing a translation may require forking an external process per path name translated. Callers should try to minimize the number of translations necessary by caching the results.
Not all platforms and JREs require path name translation. Currently only Cygwin on Win32 require translation for Cygwin based paths.
[中]将此文件解析为JRE可以使用的实际路径名。
这种方法可能相对昂贵。计算转换可能需要为每个转换的路径名分叉一个外部进程。调用者应该通过缓存结果来尽量减少必要的翻译次数。
并非所有平台和JRE都需要路径名转换。目前,Win32上只有Cygwin需要转换基于Cygwin的路径。
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
RefDirectory(FileRepository db) {
final FS fs = db.getFS();
parent = db;
gitDir = db.getDirectory();
refsDir = fs.resolve(gitDir, R_REFS);
logsDir = fs.resolve(gitDir, LOGS);
logsRefsDir = fs.resolve(gitDir, LOGS + '/' + R_REFS);
packedRefsFile = fs.resolve(gitDir, PACKED_REFS);
looseRefs.set(RefList.<LooseRef> emptyList());
packedRefs.set(NO_PACKED_REFS);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private AlternateHandle openAlternate(String location)
throws IOException {
final File objdir = fs.resolve(objects, location);
return openAlternate(objdir);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Guess if a directory contains a Git repository.
* <p>
* This method guesses by looking for the existence of some key files
* and directories.
*
* @param dir
* the location of the directory to examine.
* @param fs
* the file system abstraction which will be necessary to
* perform certain file system operations.
* @return true if the directory "looks like" a Git repository; false if
* it doesn't look enough like a Git directory to really be a
* Git directory.
*/
public static boolean isGitRepository(File dir, FS fs) {
return fs.resolve(dir, "objects").exists() //$NON-NLS-1$
&& fs.resolve(dir, "refs").exists() //$NON-NLS-1$
&& isValidHead(new File(dir, Constants.HEAD));
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* {@inheritDoc}
*
* @since 4.10
*/
@Override
protected byte[] readIncludedConfig(String relPath)
throws ConfigInvalidException {
final File file;
if (relPath.startsWith("~/")) { //$NON-NLS-1$
file = fs.resolve(fs.userHome(), relPath.substring(2));
} else {
file = fs.resolve(configFile.getParentFile(), relPath);
}
if (!file.exists()) {
return null;
}
try {
return IO.readFully(file);
} catch (IOException ioe) {
throw new ConfigInvalidException(MessageFormat
.format(JGitText.get().cannotReadFile, relPath), ioe);
}
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
@Override
public Transport open(URIish uri) throws NotSupportedException,
TransportException {
if ("bundle".equals(uri.getScheme())) { //$NON-NLS-1$
File path = FS.DETECTED.resolve(new File("."), uri.getPath()); //$NON-NLS-1$
return new TransportBundleFile(uri, path);
}
return TransportLocal.PROTO_LOCAL.open(uri);
}
};
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
@Override
public Transport open(URIish uri, Repository local, String remoteName)
throws NotSupportedException, TransportException {
if ("bundle".equals(uri.getScheme())) { //$NON-NLS-1$
File path = FS.DETECTED.resolve(new File("."), uri.getPath()); //$NON-NLS-1$
return new TransportBundleFile(local, uri, path);
}
// This is an ambiguous reference, it could be a bundle file
// or it could be a Git repository. Allow TransportLocal to
// resolve the path and figure out which type it is by testing
// the target.
//
return TransportLocal.PROTO_LOCAL.open(uri, local, remoteName);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private static File getSymRef(File workTree, File dotGit, FS fs)
throws IOException {
byte[] content = IO.readFully(dotGit);
if (!isSymRef(content))
throw new IOException(MessageFormat.format(
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
int pathStart = 8;
int lineEnd = RawParseUtils.nextLF(content, pathStart);
while (content[lineEnd - 1] == '\n' ||
(content[lineEnd - 1] == '\r' && SystemReader.getInstance().isWindows()))
lineEnd--;
if (lineEnd == pathStart)
throw new IOException(MessageFormat.format(
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
String gitdirPath = RawParseUtils.decode(content, pathStart, lineEnd);
File gitdirFile = fs.resolve(workTree, gitdirPath);
if (gitdirFile.isAbsolute())
return gitdirFile;
else
return new File(workTree, gitdirPath).getCanonicalFile();
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Load the attributes node
*
* @return the attributes node
* @throws java.io.IOException
*/
public AttributesNode load() throws IOException {
AttributesNode r = new AttributesNode();
FS fs = repository.getFS();
String path = repository.getConfig().get(CoreConfig.KEY)
.getAttributesFile();
if (path != null) {
File attributesFile;
if (path.startsWith("~/")) { //$NON-NLS-1$
attributesFile = fs.resolve(fs.userHome(),
path.substring(2));
} else {
attributesFile = fs.resolve(null, path);
}
FileRepository.AttributesNodeProviderImpl.loadRulesFromFile(r, attributesFile);
}
return r.getRules().isEmpty() ? null : r;
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Load the attributes node
*
* @return the attributes node
* @throws java.io.IOException
*/
public AttributesNode load() throws IOException {
AttributesNode r = new AttributesNode();
FS fs = repository.getFS();
File attributes = fs.resolve(repository.getDirectory(),
Constants.INFO_ATTRIBUTES);
FileRepository.AttributesNodeProviderImpl.loadRulesFromFile(r, attributes);
return r.getRules().isEmpty() ? null : r;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
@Override
public Transport open(URIish uri) throws NotSupportedException,
TransportException {
File path = FS.DETECTED.resolve(new File("."), uri.getPath()); //$NON-NLS-1$
// If the reference is to a local file, C Git behavior says
// assume this is a bundle, since repositories are directories.
if (path.isFile())
return new TransportBundleFile(uri, path);
File gitDir = RepositoryCache.FileKey.resolve(path, FS.DETECTED);
if (gitDir == null)
throw new NoRemoteRepositoryException(uri,
JGitText.get().notFound);
return new TransportLocal(uri, gitDir);
}
};
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
@Override
IgnoreNode load() throws IOException {
IgnoreNode r;
if (entry != null) {
r = super.load();
if (r == null)
r = new IgnoreNode();
} else {
r = new IgnoreNode();
}
FS fs = repository.getFS();
String path = repository.getConfig().get(CoreConfig.KEY)
.getExcludesFile();
if (path != null) {
File excludesfile;
if (path.startsWith("~/")) //$NON-NLS-1$
excludesfile = fs.resolve(fs.userHome(), path.substring(2));
else
excludesfile = fs.resolve(null, path);
loadRulesFromFile(r, excludesfile);
}
File exclude = fs.resolve(repository.getDirectory(),
Constants.INFO_EXCLUDE);
loadRulesFromFile(r, exclude);
return r.getRules().isEmpty() ? null : r;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Configure the internal implementation details of the repository.
*
* @throws java.io.IOException
* the repository could not be accessed
*/
protected void setupInternals() throws IOException {
if (getObjectDirectory() == null && getGitDir() != null)
setObjectDirectory(safeFS().resolve(getGitDir(), "objects")); //$NON-NLS-1$
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private File guessWorkTreeOrFail() throws IOException {
final Config cfg = getConfig();
// If set, core.worktree wins.
//
String path = cfg.getString(CONFIG_CORE_SECTION, null,
CONFIG_KEY_WORKTREE);
if (path != null)
return safeFS().resolve(getGitDir(), path).getCanonicalFile();
// If core.bare is set, honor its value. Assume workTree is
// the parent directory of the repository.
//
if (cfg.getString(CONFIG_CORE_SECTION, null, CONFIG_KEY_BARE) != null) {
if (cfg.getBoolean(CONFIG_CORE_SECTION, CONFIG_KEY_BARE, true)) {
setBare();
return null;
}
return getGitDir().getParentFile();
}
if (getGitDir().getName().equals(DOT_GIT)) {
// No value for the "bare" flag, but gitDir is named ".git",
// use the parent of the directory
//
return getGitDir().getParentFile();
}
// We have to assume we are bare.
//
setBare();
return null;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Parse and load the repository specific configuration.
* <p>
* The default implementation reads {@code gitDir/config}, or returns an
* empty configuration if gitDir was not set.
*
* @return the repository's configuration.
* @throws java.io.IOException
* the configuration is not available.
*/
protected Config loadConfig() throws IOException {
if (getGitDir() != null) {
// We only want the repository's configuration file, and not
// the user file, as these parameters must be unique to this
// repository and not inherited from other files.
//
File path = safeFS().resolve(getGitDir(), Constants.CONFIG);
FileBasedConfig cfg = new FileBasedConfig(path, safeFS());
try {
cfg.load();
} catch (ConfigInvalidException err) {
throw new IllegalArgumentException(MessageFormat.format(
JGitText.get().repositoryConfigFileInvalid, path
.getAbsolutePath(), err.getMessage()));
}
return cfg;
} else {
return new Config();
}
}
代码示例来源:origin: diffplug/spotless
FS fs = FS.detect();
if (globalAttributesPath.startsWith("~/")) { //$NON-NLS-1$
globalAttributesFile = fs.resolve(fs.userHome(), globalAttributesPath.substring(2));
} else {
globalAttributesFile = fs.resolve(null, globalAttributesPath);
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
@Override
public Transport open(URIish uri, Repository local, String remoteName)
throws NoRemoteRepositoryException {
File localPath = local.isBare() ? local.getDirectory() : local.getWorkTree();
File path = local.getFS().resolve(localPath, uri.getPath());
// If the reference is to a local file, C Git behavior says
// assume this is a bundle, since repositories are directories.
if (path.isFile())
return new TransportBundleFile(local, uri, path);
File gitDir = RepositoryCache.FileKey.resolve(path, local.getFS());
if (gitDir == null)
throw new NoRemoteRepositoryException(uri, JGitText.get().notFound);
return new TransportLocal(local, uri, gitDir);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
userConfig = SystemReader.getInstance().openUserConfig(systemConfig,
getFS());
repoConfig = new FileBasedConfig(userConfig, getFS().resolve(
getDirectory(), Constants.CONFIG),
getFS());
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
private AlternateHandle openAlternate(final String location)
throws IOException {
final File objdir = fs.resolve(objects, location);
return openAlternate(objdir);
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
RefDirectory(final FileRepository db) {
final FS fs = db.getFS();
parent = db;
gitDir = db.getDirectory();
logWriter = new ReflogWriter(db);
refsDir = fs.resolve(gitDir, R_REFS);
packedRefsFile = fs.resolve(gitDir, PACKED_REFS);
looseRefs.set(RefList.<LooseRef> emptyList());
packedRefs.set(PackedRefList.NO_PACKED_REFS);
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
/**
* @return the attributes node
* @throws IOException
*/
public AttributesNode load() throws IOException {
AttributesNode r = new AttributesNode();
FS fs = repository.getFS();
File attributes = fs.resolve(repository.getDirectory(),
Constants.INFO_ATTRIBUTES);
FileRepository.AttributesNodeProviderImpl.loadRulesFromFile(r, attributes);
return r.getRules().isEmpty() ? null : r;
}
内容来源于网络,如有侵权,请联系作者删除!