本文整理匯總了Java中org.eclipse.jgit.util.FS.userHome方法的典型用法代碼示例。如果您正苦於以下問題:Java FS.userHome方法的具體用法?Java FS.userHome怎麽用?Java FS.userHome使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jgit.util.FS
的用法示例。
在下文中一共展示了FS.userHome方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: knownHosts
import org.eclipse.jgit.util.FS; //導入方法依賴的package包/類
private static void knownHosts(final JSch sch, FS fs) throws JSchException {
final File home = fs.userHome();
if (home == null)
return;
final File known_hosts = new File(new File(home, ".ssh"), "known_hosts"); //$NON-NLS-1$ //$NON-NLS-2$
try {
final FileInputStream in = new FileInputStream(known_hosts);
try {
sch.setKnownHosts(in);
} finally {
in.close();
}
} catch (FileNotFoundException none) {
// Oh well. They don't have a known hosts in home.
} catch (IOException err) {
// Oh well. They don't have a known hosts in home.
}
}
示例2: getJSch
import org.eclipse.jgit.util.FS; //導入方法依賴的package包/類
@Override
protected JSch getJSch(OpenSshConfig.Host hc, FS fs) throws JSchException {
JSch jsch = super.getJSch(hc, fs);
if (StringUtils.hasValue(passphrase)) {
// If passphrase is set, add it to identity
File sshDir = new File(fs.userHome(), ".ssh");
if (sshDir.isDirectory()) {
updateIdentity(jsch, new File(sshDir, "identity"));
updateIdentity(jsch, new File(sshDir, "id_rsa"));
updateIdentity(jsch, new File(sshDir, "id_dsa"));
}
}
return jsch;
}
示例3: identities
import org.eclipse.jgit.util.FS; //導入方法依賴的package包/類
private static void identities(final JSch sch, FS fs) {
final File home = fs.userHome();
if (home == null)
return;
final File sshdir = new File(home, ".ssh"); //$NON-NLS-1$
if (sshdir.isDirectory()) {
loadIdentity(sch, new File(sshdir, "identity")); //$NON-NLS-1$
loadIdentity(sch, new File(sshdir, "id_rsa")); //$NON-NLS-1$
loadIdentity(sch, new File(sshdir, "id_dsa")); //$NON-NLS-1$
}
}
示例4: setRepository
import org.eclipse.jgit.util.FS; //導入方法依賴的package包/類
/**
* Sets the git repository. File path must exist
*
* @param path
* - A string that specifies the git Repository folder
*/
public void setRepository(String path) throws IOException {
File currentRepo = new File(path + "/.git");
boolean sameOldRepo = git != null && currentRepo.equals(git.getRepository().getDirectory());
// Change the repository only if it is a different one
if (!sameOldRepo ) {
if (git != null) {
// Stop intercepting authentication requests.
AuthenticationInterceptor.unbind(getHostName());
git.close();
}
git = Git.open(currentRepo);
// Start intercepting authentication requests.
AuthenticationInterceptor.bind(getHostName());
if (logger.isDebugEnabled()) {
// Debug data for the SSH key load location.
logger.debug("Java env user home: " + System.getProperty("user.home"));
logger.debug("Load repository " + path);
try {
FS fs = getRepository().getFS();
if (fs != null) {
File userHome = fs.userHome();
logger.debug("User home " + userHome);
File sshDir = new File(userHome, ".ssh");
boolean exists = sshDir.exists();
logger.debug("SSH dir exists " + exists);
if (exists) {
File[] listFiles = sshDir.listFiles();
for (int i = 0; i < listFiles.length; i++) {
logger.debug("SSH resource path " + listFiles[i]);
}
}
} else {
logger.debug("Null FS");
}
} catch (NoRepositorySelected e) {
logger.debug(e, e);
}
}
fireRepositoryChanged();
}
}