Exemple #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();
            });
        }
Exemple #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);
        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;
        }
        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);
        }
Exemple #5
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());
        }
        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;
        }