示例#1
0
        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);
        }
示例#2
0
文件: FS.cs 项目: kkl713/GitSharp
        /// <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);
        }
示例#3
0
        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;
        }
示例#4
0
        /// <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;
        }
示例#6
0
 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();
 }
示例#7
0
文件: FS.cs 项目: kkl713/GitSharp
        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);
        }
示例#8
0
        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);
        }
示例#9
0
 public override FileBasedConfig getConfigFile(string fileLocation)
 {
     return(SystemReader.getInstance().getConfigFile(fileLocation));
 }
示例#10
0
 public override FileBasedConfig getConfigFile(ConfigFileType fileType)
 {
     return(SystemReader.getInstance().getConfigFile(fileType));
 }
示例#11
0
文件: URIish.cs 项目: kkl713/GitSharp
 private SystemReader system()
 {
     return(SystemReader.getInstance());
 }
示例#12
0
 public override FileBasedConfig getConfigFile(string gitdir)
 {
     return(SystemReader.getInstance().getConfigFile(gitdir));
 }
 public override void Start(int totalTasks)
 {
     _taskBeganAt = SystemReader.getInstance().getCurrentTime();
     _lastOutput = _taskBeganAt;
 }