/// <summary>
        /// On click 'Update package' callback.
        /// </summary>
        public void UpdateClick()
        {
            Debug.Log(kHeader, "[UpdateClick]");
            var selectedPackage = GetSelectedPackage();

            if (selectedPackage.source == PackageSource.Git)
            {
                string packageId = selectedPackage.packageId;
                string url       = PackageUtils.GetRepoUrl(packageId);
#if UNITY_2019_3_OR_NEWER
                string refName = GetSelectedVersion().packageInfo.git.revision;
#else
                string refName       = GetSelectedVersion().VersionId.Split('@')[1];
                var    originRefName = refName;

                // Find correct reference (branch or tag) name.
                while (!AvailableVersions.GetVersions(selectedPackage.name, url).Any(x => x.refName == refName))
                {
                    var index = refName.IndexOf('-');
                    if (index < 0 || refName.Length < 1)
                    {
                        throw new Exception($"Cannot install '{packageId}'. The branch or tag is not found in repository.");
                    }
                    refName = refName.Substring(index + 1);
                }
#endif
                PackageUtils.UninstallPackage(selectedPackage.name);
                PackageUtils.InstallPackage(selectedPackage.name, url, refName);
            }
            else
            {
                packageDetails.UpdateClick();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Update available versions for git packages.
 /// </summary>
 public static void UpdateAvailableVersionsForGitPackages()
 {
     // Start update task.
     foreach (var package in PackageExtensions.GetGitPackages())
     {
         var pInfo   = package.GetInstalledVersion().GetPackageInfo();
         var repoUrl = PackageUtils.GetRepoUrl(pInfo.packageId);
         Debug.Log(kHeader, $"[UpdateAvailableVersionsForGitPackages] {pInfo.packageId} => {pInfo.name}, {repoUrl}");
         AvailableVersionExtensions.UpdateAvailableVersions(pInfo.name, repoUrl);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Update all infomations of git packages.
        /// </summary>
        public static void UpdateGitPackageVersions()
        {
            bool changed = false;

            // Start update task.
            foreach (var package in PackageExtensions.GetGitPackages())
            {
                var pInfo    = package.GetInstalledVersion().GetPackageInfo();
                var repoUrl  = PackageUtils.GetRepoUrl(pInfo.packageId);
                var versions = AvailableVersions.GetVersions(package.GetName(), repoUrl);
                Debug.Log(kHeader, $"[UpdateGitPackageVersions] {pInfo.packageId} => {package.GetName()}, {repoUrl}, {versions.Count()}");
                changed = UpdatePackageVersions(package, versions) | changed;
            }

            if (changed)
            {
                UpdatePackageCollection();
            }
        }
 /// <summary>
 /// On click 'View repository' callback.
 /// </summary>
 public void ViewRepoClick()
 {
     Application.OpenURL(PackageUtils.GetRepoUrl(GetSelectedPackage().packageId, true));
 }