Пример #1
0
        public static void Migrate(IServiceProvider serviceProvider, string basePath, string migrationModule, string repositoryUrl, bool force)
        {
            Validate(serviceProvider, basePath, migrationModule, repositoryUrl, force);

            var repositoryMigrator = CremaBootstrapper.GetRepositoryMigrator(serviceProvider, migrationModule ?? "svn");
            var logService         = new LogService("migrate", basePath)
            {
                LogLevel = LogLevel.Info
            };
            var repositoryPath    = Path.Combine(basePath, CremaString.Repository);
            var repositoryExisted = Directory.Exists(repositoryPath);

            try
            {
                if (repositoryExisted == true)
                {
                    DirectoryUtility.Backup(repositoryPath);
                }
                var url      = repositoryUrl == null ? null : new Uri(repositoryUrl, UriKind.RelativeOrAbsolute);
                var migrator = new RepositoryMigrator(logService, repositoryMigrator, basePath, url);
                migrator.Migrate();
                FileUtility.WriteAllText(Resources.Text_README, basePath, "README.md");
            }
            catch (Exception e)
            {
                logService.Error(e);
                throw;
            }
            finally
            {
                if (repositoryExisted == true)
                {
                    DirectoryUtility.Clean(repositoryPath);
                }
            }
        }
Пример #2
0
 public static void MigrateRepository(IServiceProvider serviceProvider, string basePath, string migrationModule, string repositoryUrl, bool force)
 {
     RepositoryMigrator.Migrate(serviceProvider, basePath, migrationModule, repositoryUrl, force);
 }