Пример #1
0
        public List<string> FindFilesOfTypeChangedBetweenTags(Arguments arguments, Repository repo)
        {
            var spinner = new ConsoleSpiner();

            var commits = repo.Commits;
            Commit lastCommit = null;

            var isLooking = false;
            var isLast = false;
            var files = new List<string>();

            foreach (var commit in commits)
            {
                spinner.Turn();

                var tree = commit.Tree;

                if (lastCommit == null)
                {
                    lastCommit = commit;
                    continue;
                }

                var parentCommitTree = lastCommit.Tree;
                lastCommit = commit;

                if (commit.Sha == arguments.StartTag || commit.Sha == arguments.EndTag)
                {
                    isLooking = !isLooking;
                    isLast = !isLooking;
                }

                if (isLooking)
                {
                    var c = repo.Diff
                        .Compare<TreeChanges>(parentCommitTree, tree)
                        .ToList();

                    c.ForEach(commitChanges =>
                    {
                        var file = commitChanges.Path;
                        if (file.EndsWith(".sql") && !files.Contains(file))
                        {
                            files.Add(file);
                        }
                    });
                }

                if (isLast)
                {
                    break;
                }
            }

            return files;
        }
Пример #2
0
        static void Main(string[] args)
        {
            var changes = new Dictionary<string, int>();
            var spinner = new ConsoleSpiner();
            Console.Write("Working....");

            using (var repo = new Repository(Directory.GetCurrentDirectory()))
            {
                var commits = repo.Commits;
                Commit lastCommit = null;

                foreach (var commit in commits)
                {
                    spinner.Turn();

                    var tree = commit.Tree;

                    if (lastCommit == null)
                    {
                        lastCommit = commit;
                        continue;
                    }

                    var parentCommitTree = lastCommit.Tree;
                    lastCommit = commit;

                    Diff(repo, parentCommitTree, tree, changes);

                    if (commit == commits.Last())
                    {
                        Diff(repo, null, tree, changes);
                    }
                }
            }

            Console.WriteLine();

            foreach (var change in changes.ToList().OrderByDescending(x => x.Value))
            {
                Console.WriteLine(change.Key + " - " + change.Value);
            }
        }