private void determineAtomicFileCreationSupport() { // @TODO: enhance SystemReader to support this without copying code AtomicFileCreation ret = getAtomicFileCreationSupportOption( SystemReader.getInstance().openUserConfig(null, this)); if (ret == AtomicFileCreation.UNDEFINED && StringUtils.isEmptyOrNull(SystemReader.getInstance() .getenv(Constants.GIT_CONFIG_NOSYSTEM_KEY))) { ret = getAtomicFileCreationSupportOption( SystemReader.getInstance().openSystemConfig(null, this)); } supportsAtomicCreateNewFile = ret; }
/** * Construct a new {@link org.eclipse.jgit.lib.PersonIdent} with current * time. * * @param aName * a {@link java.lang.String} object. * @param aEmailAddress * a {@link java.lang.String} object. */ public PersonIdent(String aName, String aEmailAddress) { this(aName, aEmailAddress, SystemReader.getInstance().getCurrentTime()); }
/** * Read target path of the symlink. * * @param path * a {@link java.io.File} object. * @return target path of the symlink, or null if it is not a symbolic link * @throws java.io.IOException * @since 3.0 */ public static String readSymLink(File path) throws IOException { Path nioPath = toPath(path); Path target = Files.readSymbolicLink(nioPath); String targetString = target.toString(); if (SystemReader.getInstance().isWindows()) { targetString = targetString.replace('\\', '/'); } else if (SystemReader.getInstance().isMacOS()) { targetString = Normalizer.normalize(targetString, Form.NFC); } return targetString; }
/** {@inheritDoc} */ @Override public boolean isCaseSensitive() { return !SystemReader.getInstance().isMacOS(); }
@Override public String run() { return SystemReader.getInstance() .getProperty(Constants.OS_USER_NAME_KEY); } });
systemConfig = SystemReader.getInstance().openSystemConfig(null, FS.DETECTED); Errors.log().run(systemConfig::load); userConfig = SystemReader.getInstance().openUserConfig(systemConfig, FS.DETECTED); Errors.log().run(userConfig::load);
/** * Convert a path to String, replacing separators as necessary. * * @param file * a {@link java.io.File}. * @return file's path as a String * @since 4.10 */ public static String pathToString(File file) { final String path = file.getPath(); if (SystemReader.getInstance().isWindows()) { return path.replace('\\', '/'); } return path; } }
private void updateSslVerifyUser(boolean value) { FileBasedConfig userConfig = SystemReader.getInstance() .openUserConfig(null, FS.DETECTED); try { userConfig.load(); updateSslVerify(userConfig, value); } catch (IOException | ConfigInvalidException e) { // Log it, but otherwise ignore here. LOG.error(MessageFormat.format(JGitText.get().userConfigFileInvalid, userConfig.getFile().getAbsolutePath(), e)); } }
private static boolean useExtSession() { return SystemReader.getInstance().getenv("GIT_SSH") != null; //$NON-NLS-1$ }
private static Date parse_relative(String dateStr, Calendar now) { Calendar cal; SystemReader sysRead = SystemReader.getInstance(); return ((now == null) ? new Date(sysRead.getCurrentTime()) : now .getTime()); cal = new GregorianCalendar(sysRead.getTimeZone(), sysRead.getLocale()); cal.setTimeInMillis(sysRead.getCurrentTime()); } else cal = (Calendar) now.clone();
public Replacer(String host, int port, String user, String localUserName, File home) { replacements.put(Character.valueOf('%'), "%"); //$NON-NLS-1$ replacements.put(Character.valueOf('d'), home.getPath()); replacements.put(Character.valueOf('h'), host); String localhost = SystemReader.getInstance().getHostname(); replacements.put(Character.valueOf('l'), localhost); int period = localhost.indexOf('.'); if (period > 0) { localhost = localhost.substring(0, period); } replacements.put(Character.valueOf('L'), localhost); replacements.put(Character.valueOf('n'), host); replacements.put(Character.valueOf('p'), Integer.toString(port)); replacements.put(Character.valueOf('r'), user == null ? "" : user); //$NON-NLS-1$ replacements.put(Character.valueOf('u'), localUserName); replacements.put(Character.valueOf('C'), substitute("%l%h%p%r", "hlpr")); //$NON-NLS-1$ //$NON-NLS-2$ replacements.put(Character.valueOf('T'), "NONE"); //$NON-NLS-1$ }
/** {@inheritDoc} */ @Override protected File discoverGitExe() { String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$ File gitExe = searchPath(path, "git"); //$NON-NLS-1$ if (gitExe == null) { if (SystemReader.getInstance().isMacOS()) { if (searchPath(path, "bash") != null) { //$NON-NLS-1$ // On MacOSX, PATH is shorter when Eclipse is launched from the // Finder than from a terminal. Therefore try to launch bash as a // login shell and search using that. String w; try { w = readPipe(userHome(), new String[]{"bash", "--login", "-c", "which git"}, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ Charset.defaultCharset().name()); } catch (CommandFailedException e) { LOG.warn(e.getMessage()); return null; } if (!StringUtils.isEmptyOrNull(w)) { gitExe = new File(w); } } } } return gitExe; }
private long getExpireDate() throws ParseException { long expireDate = Long.MAX_VALUE; if (expire == null && expireAgeMillis == -1) { String pruneExpireStr = getPruneExpireStr(); if (pruneExpireStr == null) pruneExpireStr = PRUNE_EXPIRE_DEFAULT; expire = GitDateParser.parse(pruneExpireStr, null, SystemReader .getInstance().getLocale()); expireAgeMillis = -1; } if (expire != null) expireDate = expire.getTime(); if (expireAgeMillis != -1) expireDate = System.currentTimeMillis() - expireAgeMillis; return expireDate; }
private PersonIdent(final String aName, final String aEmailAddress, long when) { this(aName, aEmailAddress, when, SystemReader.getInstance() .getTimezone(when)); }
private static SimpleDateFormat getNewSimpleDateFormat( ParseableSimpleDateFormat f, Locale locale, Map<ParseableSimpleDateFormat, SimpleDateFormat> map) { SimpleDateFormat df = SystemReader.getInstance().getSimpleDateFormat( f.formatStr, locale); map.put(f, df); return df; }
private static long dayStartInMillis(long timeInMillis) { Calendar cal = new GregorianCalendar( SystemReader.getInstance().getTimeZone()); cal.setTimeInMillis(timeInMillis); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTimeInMillis(); }
@Override protected void setChangeSystemPrefix(String prefix) throws IOException { FS.DETECTED.setGitPrefix(new File(prefix)); sysConfig = SystemReader.getInstance().openSystemConfig(null, FS.DETECTED); setConfig(sysConfig); }
private static void checkPath(byte[] path) { try { SystemReader.getInstance().checkPath(path); } catch (CorruptObjectException e) { InvalidPathException p = new InvalidPathException(toString(path)); p.initCause(e); throw p; } }
private static SystemReader system() { return SystemReader.getInstance(); } }