Ejemplo n.º 1
0
        public Command GetQueryFilesToCleanCommand(CleanFilesParameters parameters)
        {
            Assert.IsNotNull(parameters);

            var args = new List<ICommandArgument>(
                (parameters.ExcludePatterns != null ? parameters.ExcludePatterns.Count : 0) +
                (parameters.Paths != null ? parameters.Paths.Count + 1 : 0) + 4);
            args.Add(CleanCommand.DryRun());
            InsertCleanFilesParameters(parameters, args);
            return new CleanCommand(args);
        }
Ejemplo n.º 2
0
 private void InsertCleanFilesParameters(CleanFilesParameters parameters, IList<ICommandArgument> args)
 {
     if(parameters.Force)
     {
         args.Add(CleanCommand.Force());
     }
     if(parameters.RemoveDirectories)
     {
         args.Add(CleanCommand.Directories());
     }
     switch(parameters.Mode)
     {
         case CleanFilesMode.IncludeIgnored:
             args.Add(CleanCommand.IncludeIgnored());
             break;
         case CleanFilesMode.OnlyIgnored:
             args.Add(CleanCommand.ExcludeUntracked());
             break;
     }
     if(parameters.ExcludePatterns != null && GitFeatures.CleanExcludeOption.IsAvailableFor(_gitCLI))
     {
         foreach(var pattern in parameters.ExcludePatterns)
         {
             if(!string.IsNullOrEmpty(pattern))
             {
                 args.Add(CleanCommand.Exclude(pattern));
             }
         }
     }
     if(parameters.Paths != null && parameters.Paths.Count != 0)
     {
         bool addedAnyPath = false;
         foreach(var path in parameters.Paths)
         {
             if(string.IsNullOrWhiteSpace(path))
             {
                 continue;
             }
             if(addedAnyPath)
             {
                 args.Add(CleanCommand.NoMoreOptions());
                 addedAnyPath = true;
             }
             args.Add(new PathCommandArgument(path));
         }
     }
 }