Beispiel #1
0
        private void ResolveGit(string workingDirectory, GitPackageMetadata gitMetadata, string folder, string templateName, bool forceUpgrade)
        {
            switch (gitMetadata.PackageType)
            {
            case PackageManager.PACKAGE_TYPE_LIBRARY:
                if (File.Exists(Path.Combine(workingDirectory, folder, ".git")) || Directory.Exists(Path.Combine(workingDirectory, folder, ".git")))
                {
                    if (!forceUpgrade)
                    {
                        RedirectableConsole.WriteLine("Git submodule / repository already present at " + folder);
                        return;
                    }
                }

                PathUtils.AggressiveDirectoryDelete(Path.Combine(workingDirectory, folder));

                var packageLibrary = GetSourcePackage(workingDirectory, gitMetadata.CloneURI);
                ExtractGitSourceTo(workingDirectory, packageLibrary, gitMetadata.GitRef, folder);
                break;

            case PackageManager.PACKAGE_TYPE_TEMPLATE:
                if (Directory.Exists(".staging"))
                {
                    PathUtils.AggressiveDirectoryDelete(Path.Combine(workingDirectory, ".staging"));
                }

                var packageTemplate = GetSourcePackage(workingDirectory, gitMetadata.CloneURI);
                ExtractGitSourceTo(workingDirectory, packageTemplate, gitMetadata.GitRef, Path.Combine(workingDirectory, ".staging"));

                _projectTemplateApplier.Apply(Path.Combine(workingDirectory, ".staging"), templateName);
                PathUtils.AggressiveDirectoryDelete(Path.Combine(workingDirectory, ".staging"));
                break;

            default:
                throw new InvalidOperationException("Unable to resolve source package with type '" + gitMetadata.PackageType + "' using Git-based package.");
            }
        }
        private void ResolveGit(GitPackageMetadata gitMetadata, string folder, string templateName, bool forceUpgrade)
        {
            switch (gitMetadata.PackageType)
            {
                case PackageManager.PACKAGE_TYPE_LIBRARY:
                    if (File.Exists(Path.Combine(folder, ".git")) || Directory.Exists(Path.Combine(folder, ".git")))
                    {
                        if (!forceUpgrade)
                        {
                            Console.WriteLine("Git submodule / repository already present at " + folder);
                            return;
                        }
                    }

                    PathUtils.AggressiveDirectoryDelete(folder);

                    var packageLibrary = GetSourcePackage(gitMetadata.CloneURI);
                    ExtractGitSourceTo(packageLibrary, gitMetadata.GitRef, folder);
                    break;
                case PackageManager.PACKAGE_TYPE_TEMPLATE:
                    if (Directory.Exists(".staging"))
                    {
                        PathUtils.AggressiveDirectoryDelete(".staging");
                    }

                    var packageTemplate = GetSourcePackage(gitMetadata.CloneURI);
                    ExtractGitSourceTo(packageTemplate, gitMetadata.GitRef, ".staging");

                    _projectTemplateApplier.Apply(".staging", templateName);
                    PathUtils.AggressiveDirectoryDelete(".staging");
                    break;
                default:
                    throw new InvalidOperationException("Unable to resolve source package with type '" + gitMetadata.PackageType + "' using Git-based package.");
            }
        }