示例#1
0
        public void TestGetInstalledPath()
        {
            package.Setup((o) => o.GetPackageType()).Returns("foo");
            installer.Setup((o) => o.IsSupports("foo")).Returns(true);
            installer.Setup((o) => o.GetInstallPath(package.Object)).Returns("bar");
            manager.AddInstaller(installer.Object);

            Assert.AreEqual("bar", manager.GetInstalledPath(package.Object));
        }
示例#2
0
        private DateTime?GetPackageTimeFromSource(IPackage package)
        {
            var      installedPath = Path.Combine(Environment.CurrentDirectory, installationManager.GetInstalledPath(package));
            var      sourceType    = package.GetSourceType();
            DateTime?ret           = null;

            if (string.IsNullOrEmpty(installedPath) || !Array.Exists(new[] { "git" }, (item) => item == sourceType))
            {
                return(null);
            }

            var sourceReference = package.GetSourceReference() ?? package.GetDistReference();

            DateTime?GetGitDateTime()
            {
                Git.CleanEnvironment();
                if (process.Execute(
                        $"git log -n1 --pretty=%aD {ProcessExecutor.Escape(sourceReference)}",
                        out string output, installedPath) == 0 &&
                    DateTime.TryParse(output.Trim(), out DateTime dateTime))
                {
                    return(dateTime);
                }

                return(null);
            }

            switch (sourceReference)
            {
            case "git":
                ret = GetGitDateTime();
                break;

            default:
                break;
            }

            return(ret);
        }