Exemple #1
0
 static IEnumerable <ObjectHash> FindCommitsWithDuplicateTreeEntries(string vcsPath)
 {
     foreach (var commit in CommitWalker
              .CommitsRandomOrder(vcsPath)
              .AsParallel()
              .AsUnordered()
              .Select(commit => (commit.Hash, Defective: HasDefectiveTree(vcsPath, commit))))
     {
         if (commit.Defective)
         {
             yield return(commit.Hash);
         }
     }
 }
Exemple #2
0
        static void Main(string[] args)
        {
            if (!CommandLineOptions.TryParse(args, out var options))
            {
                return;
            }

            PackReader.InitializePackFiles(options.RepositoryPath);

            if (options.FixTrees)
            {
                var defectiveCommits = FindCommitsWithDuplicateTreeEntries(options.RepositoryPath).ToList();

                var rewrittenCommits = FixDefectiveCommits(options.RepositoryPath, defectiveCommits);
                if (rewrittenCommits.Any())
                {
                    Refs.Update(options.RepositoryPath, rewrittenCommits);
                }
            }
            else if (options.FilesToDelete.Any() || options.FoldersToDelete.Any())
            {
                using (var task = new DeletionTask(options.RepositoryPath, options.FilesToDelete, options.FoldersToDelete, options.ProtectRefs))
                    task.Run();
            }
            else if (options.RemoveEmptyCommits)
            {
                using (var removeEmptyCommitsTask = new RemoveEmptyCommitsTask(options.RepositoryPath))
                    removeEmptyCommitsTask.Run();
            }
            else if (!string.IsNullOrWhiteSpace(options.ContributorMappingFile))
            {
                using (var rewriteContributorTask = new RewriteContributorTask(options.RepositoryPath, options.ContributorMappingFile))
                    rewriteContributorTask.Run();
            }
            else if (options.ListContributorNames)
            {
                foreach (var contributor in CommitWalker.CommitsRandomOrder(options.RepositoryPath)
                         .SelectMany(commit => new[] { commit.GetAuthorName(), commit.GetCommitterName() })
                         .Distinct()
                         .AsParallel()
                         .OrderBy(x => x))
                {
                    Console.WriteLine(contributor);
                }
            }
        }