Ejemplo n.º 1
0
        static Action NewGitInitializeRepositoryAction(ActionContext context)
        {
            var gitClient = new CommandLineClient(context.Parameters.LocalWorkspacePath, context.Logger);
            var gitFacade = new CommandLineClientFacade(gitClient, new FileSystem());

            return new GitInitializeLocalRepositoryAction(context, gitFacade).Execute;
        }
Ejemplo n.º 2
0
 public GitCommitFilesAction(ActionContext context, CommandLineClient gitClient)
 {
     Guard.That(context).IsNotNull();
     Guard.That(gitClient).IsNotNull();
     this.context = context;
     this.gitClient = gitClient;
 }
Ejemplo n.º 3
0
 public PrepareWorkspaceAction(ActionContext context, IFileSystem fileSystem)
 {
     Guard.That(context).IsNotNull();
     Guard.That(fileSystem).IsNotNull();
     this.context = context;
     this.fileSystem = fileSystem;
 }
 public GitInitializeLocalRepositoryAction(ActionContext context, IGitFacade gitFacade)
 {
     Guard.That(context).IsNotNull();
     Guard.That(gitFacade).IsNotNull();
     this.context = context;
     this.gitFacade = gitFacade;
     exporterEmail = string.Format("vault-exporter@{0}", context.Parameters.CommitAuthorEmailDomain);
 }
 public void Action_context_with_parameters()
 {
     actionContext = new ActionContext(new Parameters
     {
         LocalWorkspacePath = @"C:\Workspace",
         CommitAuthorEmailDomain = "example.org"
     }, Substitute.For<ILogger>());
 }
Ejemplo n.º 6
0
        public Action Compose(ActionKind actionKind, ActionContext context)
        {
            Guard.That(context).IsNotNull();

            var actionConstructor = GetConstructorFor(actionKind);
            var action = actionConstructor(context);

            var prepareWorkspaceAction = NewPrepareWorkspaceAction(context);
            return (Action) Delegate.Combine(prepareWorkspaceAction, action);
        }
Ejemplo n.º 7
0
 public VaultExportAction(ActionContext context, VaultFacade vaultFacade,
     ILastVersionMarker lastVersionMarker, DirectoryCleaner directoryCleaner,
     Action<VersionHistoryItem> versionDownloadedSubAction)
 {
     this.context = context;
     this.vaultFacade = vaultFacade;
     this.versionDownloadedSubAction = versionDownloadedSubAction;
     this.lastVersionMarker = lastVersionMarker;
     this.directoryCleaner = directoryCleaner;
 }
Ejemplo n.º 8
0
        static Action NewVaultExportAction(ActionContext context)
        {
            var vaultCredential = new NetworkCredential(context.Parameters.VaultUserName,
                context.Parameters.VaultPassword);
            var vaultClient = new VaultExport.Interop.CommandLineClient(context.Parameters.VaultCommandLineClientPath,
                context.Parameters.VaultHost, vaultCredential,
                TimeSpan.FromSeconds(context.Parameters.VaultServerTimeOutInSeconds));
            var vaultFactory = new VaultFacade(vaultClient);

            var gitClient = new CommandLineClient(context.Parameters.LocalWorkspacePath, context.Logger);
            var versionMarker = new FilePersistedLastVersionMarker(context.Parameters.LocalWorkspacePath, new FileSystem());

            Action<VersionHistoryItem> versionDownloadedAction =
                new GitCommitFilesAction(context, gitClient).Execute;

            return
                new VaultExportAction(context, vaultFactory, versionMarker, new DirectoryCleaner(new FileSystem()),
                    versionDownloadedAction).Execute;
        }
Ejemplo n.º 9
0
        public static void Main(params string[] args)
        {
            ILogger logger = new ConsoleLoggerWithProgressIndicator();

            try
            {
                var parameters = Args.Parse<Parameters>(args);
                if (parameters == null)
                    return;

                var context = new ActionContext(parameters, logger);
                var action = new ActionComposer().Compose(parameters.Action, context);
                var timedAction = new TimedAction(action);
                timedAction.Execute();

                Console.WriteLine("Completed, action took {0}", timedAction.Duration);
            }
            catch (Exception e)
            {
                logger.LogInfo("An error occured: {0}", e);
                throw;
            }
        }
 public void Action_context_with_path_to_workspace()
 {
     actionContext = new ActionContext(fixture.Create<Parameters>(), Substitute.For<ILogger>());
 }
Ejemplo n.º 11
0
 static Action NewWorkspaceInitAction(ActionContext context)
 {
     return (Action) Delegate.Combine(
         NewGitInitializeRepositoryAction(context),
         NewPrepareEmptyVersionMarkerAction(context));
 }
Ejemplo n.º 12
0
 static Action NewPrepareWorkspaceAction(ActionContext context)
 {
     return new PrepareWorkspaceAction(context, new FileSystem()).Execute;
 }
Ejemplo n.º 13
0
 static Action NewPrepareEmptyVersionMarkerAction(ActionContext context)
 {
     var versionMarker = new FilePersistedLastVersionMarker(context.Parameters.LocalWorkspacePath, new FileSystem());
     return new WriteNoVersionMarkerAction(versionMarker).Execute;
 }