public static bool IsRunningOn(AssertedPlatform assertedPlatform) { SystemReader systemReader = SystemReader.getInstance(); bool isRunningOnUnknownOS = (systemReader.getOperatingSystem() == PlatformType.Unknown); if (isRunningOnUnknownOS) { return(false); } bool isRunningOnWindows = (systemReader.getOperatingSystem() == PlatformType.Windows); if (isRunningOnWindows && assertedPlatform == AssertedPlatform.Windows) { return(true); } if (!isRunningOnWindows && assertedPlatform == AssertedPlatform.Mono) { return(true); } return(false); }
/// <summary> /// Returns the system-wide path for application settings based on OS /// </summary> /// <returns></returns> public static string getCommonAppDataPath() { string path = string.Empty; PlatformType ptype = SystemReader.getInstance().getOperatingSystem(); switch (ptype) { case PlatformType.Windows: path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); break; case PlatformType.Unix: path = "~(prefix)/etc"; break; case PlatformType.MacOSX: path = "~(prefix)/etc"; break; case PlatformType.Xbox: default: throw new ArgumentException("CommonAppData support for '" + Environment.OSVersion.VersionString + " ' is not implemented."); } return(path); }
private void writePack(IDictionary <string, RemoteRefUpdate> refUpdates, ProgressMonitor monitor) { PackWriter writer = new PackWriter(local, monitor); List <ObjectId> remoteObjects = new List <ObjectId>(Refs.Count); List <ObjectId> newObjects = new List <ObjectId>(refUpdates.Count); foreach (Ref r in Refs) { remoteObjects.Add(r.ObjectId); } remoteObjects.AddRange(additionalHaves); foreach (RemoteRefUpdate r in refUpdates.Values) { if (!ObjectId.ZeroId.Equals(r.NewObjectId)) { newObjects.Add(r.NewObjectId); } } writer.Thin = _thinPack; writer.DeltaBaseAsOffset = _capableOfsDelta; writer.preparePack(newObjects, remoteObjects); long start = SystemReader.getInstance().getCurrentTime(); writer.writePack(outStream); packTransferTime = SystemReader.getInstance().getCurrentTime() - start; }
/// <summary> /// Returns the system-wide path for application settings based on OS /// </summary> /// <returns></returns> public static DirectoryInfo systemHomeImpl() { string path = string.Empty; PlatformType ptype = SystemReader.getInstance().getOperatingSystem(); switch (ptype) { case PlatformType.Windows: path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GitSharp"); break; case PlatformType.Unix: path = "~(prefix)/etc"; break; case PlatformType.MacOSX: path = "~(prefix)/etc"; break; case PlatformType.Xbox: default: throw new ArgumentException("SystemHomeImpl support for '" + Environment.OSVersion.VersionString + " ' is not implemented."); } return(new DirectoryInfo(path)); }
public override void Update(int completed) { if (_msg == null) return; int cmp = _lastWorked + completed; long now = SystemReader.getInstance().getCurrentTime(); if (!_output && now - _taskBeganAt < 500) return; if (_totalWork == UNKNOWN) { if (now - _lastOutput >= 500) { display(cmp, null); _lastOutput = now; } } else { if ((cmp * 100 / _totalWork) != (_lastWorked * 100) / _totalWork || now - _lastOutput >= 500) { display(cmp, null); _lastOutput = now; } } _lastWorked = cmp; _output = true; }
public MockSystemReader() { init(Constants.OS_USER_NAME_KEY); init(Constants.GIT_AUTHOR_NAME_KEY); init(Constants.GIT_AUTHOR_EMAIL_KEY); init(Constants.GIT_COMMITTER_NAME_KEY); init(Constants.GIT_COMMITTER_EMAIL_KEY); userGitConfig = new MockFileBasedConfig(null); operatingSystem = SystemReader.getInstance().getOperatingSystem(); }
public static string getAppStorePrefix() { string prefix = string.Empty; PlatformType ptype = SystemReader.getInstance().getOperatingSystem(); switch (ptype) { case PlatformType.Windows: prefix = "GitSharp"; break; case PlatformType.Unix: case PlatformType.MacOSX: case PlatformType.Xbox: default: break; } return(prefix); }
public void testEnsureLogTimeAndTimeZoneOffsetAreCurrentValues() { long commitTime = 1154236443000L; int tz = -4 * 60; Core.Tree t = new Core.Tree(db); addFileToTree(t, "i-am-a-file", "and this is the data in me\n"); commit(t, "A Commit\n", new PersonIdent(author, commitTime, tz), new PersonIdent(committer, commitTime, tz)); IList <ReflogReader.Entry> entries = db.ReflogReader(Constants.HEAD).getReverseEntries(); Assert.AreEqual(1, entries.Count); var entry = entries[0]; SystemReader mockSystemReader = SystemReader.getInstance(); long fakeCurrentTime = mockSystemReader.getCurrentTime(); long remainder = fakeCurrentTime % 1000; fakeCurrentTime -= remainder; // Second based Unix time format is used to store timetamps in the log. Thus, milliseconds are truncated. Assert.AreEqual(fakeCurrentTime, entry.getWho().When); Assert.AreEqual(mockSystemReader.getTimezone(fakeCurrentTime), entry.getWho().TimeZoneOffset); }
public override FileBasedConfig getConfigFile(string fileLocation) { return(SystemReader.getInstance().getConfigFile(fileLocation)); }
public override FileBasedConfig getConfigFile(ConfigFileType fileType) { return(SystemReader.getInstance().getConfigFile(fileType)); }
private SystemReader system() { return(SystemReader.getInstance()); }
public override FileBasedConfig getConfigFile(string gitdir) { return(SystemReader.getInstance().getConfigFile(gitdir)); }
public override void Start(int totalTasks) { _taskBeganAt = SystemReader.getInstance().getCurrentTime(); _lastOutput = _taskBeganAt; }