示例#1
0
        private void InitializeCommitCount()
        {
            ThreadHelper.JoinableTaskFactory.RunAsync(
                async() =>
            {
                await TaskScheduler.Default.SwitchTo(alwaysYield: true);

                var(commitsPerUser, totalCommits) = CommitCounter.GroupAllCommitsByContributor(_module);

                await this.SwitchToMainThreadAsync();

                TotalCommits.Text = string.Format(_commits.Text, totalCommits);

                var builder = new StringBuilder();

                var commitCountValues = new decimal[commitsPerUser.Count];
                var commitCountLabels = new string[commitsPerUser.Count];
                var n = 0;
                foreach (var(user, commits) in commitsPerUser)
                {
                    builder.AppendLine($"{commits:N0} {user}");

                    commitCountValues[n] = commits;
                    commitCountLabels[n] = string.Format(_commitsBy.Text, commits, user);
                    n++;
                }

                CommitCountPie.SetValues(commitCountValues);
                CommitCountPie.ToolTips = commitCountLabels;

                CommitStatistics.Text = builder.ToString();
            });
        }
示例#2
0
        private void InitializeCommitCount()
        {
            Action <FormGitStatistics> a = sender =>
            {
                var(commitsPerUser, totalCommits) = CommitCounter.GroupAllCommitsByContributor(_module);

                _syncContext.Post(o =>
                {
                    if (IsDisposed)
                    {
                        return;
                    }

                    TotalCommits.Text = string.Format(_commits.Text, totalCommits);

                    var builder = new StringBuilder();

                    var commitCountValues = new decimal[commitsPerUser.Count];
                    var commitCountLabels = new string[commitsPerUser.Count];
                    var n = 0;
                    foreach (var(user, commits) in commitsPerUser)
                    {
                        builder.AppendLine(commits + " " + user);

                        commitCountValues[n] = commits;
                        commitCountLabels[n] = string.Format(_commitsBy.Text, commits, user);
                        n++;
                    }

                    CommitCountPie.SetValues(commitCountValues);
                    CommitCountPie.ToolTips = commitCountLabels;

                    CommitStatistics.Text = builder.ToString();
                }, null);
        public void CanCountCommitsWithMockedRepository()
        {
            var commitLog = Mock.Of<CommitLog>(cl => cl.GetEnumerator() == FakeCommitLog(17));
            var repo = Mock.Of<IRepository>(r => r.Commits == commitLog);

            var commitCounter = new CommitCounter(repo);
            Assert.Equal(17, commitCounter.NumberOfCommits);
        }
 public void CanCountCommitsWithConcreteRepository()
 {
     using (var repo = new Repository(BareTestRepoPath))
     {
         var commitCounter = new CommitCounter(repo);
         Assert.Equal(7, commitCounter.NumberOfCommits);
     }
 }
示例#5
0
 public void CanCountCommitsWithConcreteRepository()
 {
     using (var repo = new Repository(BareTestRepoPath))
     {
         var commitCounter = new CommitCounter(repo);
         Assert.Equal(7, commitCounter.NumberOfCommits);
     }
 }
        public void CanCountCommitsWithMockedRepository()
        {
            var commitLog = Mock.Of <IQueryableCommitLog>(cl => cl.GetEnumerator() == FakeCommitLog(17));
            var repo      = Mock.Of <IRepository>(r => r.Commits == commitLog);

            var commitCounter = new CommitCounter(repo);

            Assert.Equal(17, commitCounter.NumberOfCommits);
        }
示例#7
0
 public void CanCountCommitsWithConcreteRepository()
 {
     string path = SandboxBareTestRepo();
     using (var repo = new Repository(path))
     {
         var commitCounter = new CommitCounter(repo);
         Assert.Equal(7, commitCounter.NumberOfCommits);
     }
 }
        public void CanCountCommitsWithConcreteRepository()
        {
            string path = SandboxBareTestRepo();

            using (var repo = new Repository(path))
            {
                var commitCounter = new CommitCounter(repo);
                Assert.Equal(7, commitCounter.NumberOfCommits);
            }
        }
示例#9
0
        private void FormCommitCountLoad(object sender, EventArgs e)
        {
            RestorePosition("commit-count");
            Loading.Visible = true;

            foreach (var keyValuePair in CommitCounter.GroupAllCommitsByContributor().Item1)
            {
                CommitCount.Text += string.Format("{1,6} - {0}\r\n", keyValuePair.Key, keyValuePair.Value);
            }

            Loading.Visible = false;
        }
示例#10
0
        private void InitializeCommitCount()
        {
            Action <FormGitStatistics> a = sender =>
            {
                var allCommitsByUser = CommitCounter.GroupAllCommitsByContributor(_module);
                _syncContext.Post(o =>
                {
                    if (IsDisposed)
                    {
                        return;
                    }

                    var totalCommits   = allCommitsByUser.Item2;
                    var commitsPerUser = allCommitsByUser.Item1;

                    TotalCommits.Text = string.Format(_commits.Text, totalCommits);

                    var builder = new StringBuilder();

                    var commitCountValues = new decimal[commitsPerUser.Count];
                    var commitCountLabels = new string[commitsPerUser.Count];
                    var n = 0;
                    foreach (var keyValuePair in commitsPerUser)
                    {
                        var user    = keyValuePair.Key;
                        var commits = keyValuePair.Value;

                        builder.AppendLine(commits + " " + user);

                        commitCountValues[n] = commits;
                        commitCountLabels[n] = string.Format(_commitsBy.Text, commits, user);
                        n++;
                    }

                    CommitCountPie.SetValues(commitCountValues);
                    CommitCountPie.ToolTips = commitCountLabels;

                    CommitStatistics.Text = builder.ToString();
                }, null);
            };

            a.BeginInvoke(null, null, this);
        }
示例#11
0
        public void RefreshTasks()
        {
            if (!FilterParameters.NeedRefresh)
            {
                return;
            }
            FilterParameters.NeedRefresh = false;

            var list = new List <TaskProxy>();

            GithubDataGetter  dataGetter = new GithubDataGetter();
            List <CommitRoot> commits    = dataGetter.GetCommitsFromAllBranches();

            CommitCounter     commitWorker = new CommitCounter(commits);
            List <CommitInfo> results      = commitWorker.PrepareDataForShow();

            foreach (CommitInfo result in results)
            {
                list.Add(new TaskProxy(result, Context));
            }
            tasks = list.ToArray();
        }
示例#12
0
        private static string GenerateText(GitModule module, bool includeSubmodules, CancellationToken token)
        {
            var text             = new StringBuilder();
            var submodulesByName = new Dictionary <string, HashSet <string> >();

            var(countByName, _) = CommitCounter.GroupAllCommitsByContributor(module);

            if (includeSubmodules)
            {
                token.ThrowIfCancellationRequested();

                var submodules = module.GetSubmodulesLocalPaths();

                foreach (var submoduleName in submodules)
                {
                    token.ThrowIfCancellationRequested();

                    var submodule = module.GetSubmodule(submoduleName);

                    if (submodule.IsValidGitWorkingDir())
                    {
                        token.ThrowIfCancellationRequested();

                        var(submoduleItems, _) = CommitCounter.GroupAllCommitsByContributor(submodule);

                        foreach (var(name, count) in submoduleItems)
                        {
                            if (!submodulesByName.ContainsKey(name))
                            {
                                submodulesByName.Add(name, new HashSet <string>());
                            }

                            submodulesByName[name].Add(submodule.SubmoduleName);

                            if (countByName.ContainsKey(name))
                            {
                                countByName[name] += count;
                            }
                            else
                            {
                                countByName.Add(name, count);
                            }
                        }
                    }
                }
            }

            foreach (var(name, count) in countByName.OrderByDescending(pair => pair.Value))
            {
                text.AppendFormat("{0,6} - {1}", count, name);

                if (submodulesByName.TryGetValue(name, out var sub))
                {
                    text.Append(" [");

                    if (sub.Count == 1)
                    {
                        text.Append(sub.Single());
                    }
                    else
                    {
                        text.Append(sub.Count).Append(" submodules");
                    }

                    text.Append("]");
                }

                text.AppendLine();
            }

            return(text.ToString());
        }
示例#13
0
        private void FetchData()
        {
            Loading.Visible = true;

            CommitCount.Text = "";
            var dict  = new Dictionary <string, HashSet <string> >();
            var items = CommitCounter.GroupAllCommitsByContributor(Module).Item1;

            if (cbIncludeSubmodules.Checked)
            {
                IList <string> submodules = Module.GetSubmodulesLocalPaths();
                foreach (var submoduleName in submodules)
                {
                    GitModule submodule = Module.GetSubmodule(submoduleName);
                    if (submodule.IsValidGitWorkingDir())
                    {
                        var submoduleItems = CommitCounter.GroupAllCommitsByContributor(submodule).Item1;
                        foreach (var keyValuePair in submoduleItems)
                        {
                            if (!dict.ContainsKey(keyValuePair.Key))
                            {
                                dict.Add(keyValuePair.Key, new HashSet <string>());
                            }

                            dict[keyValuePair.Key].Add(submodule.SubmoduleName);
                            if (items.ContainsKey(keyValuePair.Key))
                            {
                                items[keyValuePair.Key] += keyValuePair.Value;
                            }
                            else
                            {
                                items.Add(keyValuePair.Key, keyValuePair.Value);
                            }
                        }
                    }
                }
            }

            var sortedItems = from pair in items
                              orderby pair.Value descending
                              select pair;

            foreach (var keyValuePair in sortedItems)
            {
                string submodulesList = "";
                if (dict.ContainsKey(keyValuePair.Key))
                {
                    var sub = dict[keyValuePair.Key];
                    if (sub.Count == 1)
                    {
                        foreach (var item in dict[keyValuePair.Key])
                        {
                            submodulesList = " [" + item + "]";
                        }
                    }
                    else
                    {
                        submodulesList = " [" + sub.Count.ToString() + " submodules]";
                    }
                }

                CommitCount.Text += string.Format("{0,6} - {1}{2}\r\n", keyValuePair.Value, keyValuePair.Key, submodulesList);
            }

            Loading.Visible = false;
        }