Пример #1
0
        private void execute(ILoadingTaskState taskState)
        {
            string authorName = this.RespectMailmap ? "%aN" : "%an";

            string command = "log --pretty=tformat:\"--- %ad --- " + authorName + "\" --numstat --date=iso -C --all --no-merges";

            LoadModuleInfo(command, GitModule.CurrentWorkingDir, taskState);

            if (ShowSubmodules)
            {
                IList <string> submodules = GitModule.Current.GetSubmodulesLocalPathes();
                foreach (var submoduleName in submodules)
                {
                    GitModule submodule = GitModule.Current.GetSubmodule(submoduleName);
                    if (submodule.ValidWorkingDir())
                    {
                        LoadModuleInfo(command, submodule.WorkingDir, taskState);
                    }
                }
            }
        }
Пример #2
0
        private void execute(ILoadingTaskState taskState)
        {
            RevisionCount = 0;
            heads = GetHeads().ToDictionaryOfList(head => head.Guid);

            string formatString =
                /* <COMMIT>       */ COMMIT_BEGIN + "%n" +
                /* Hash           */ "%H%n" +
                /* Parents        */ "%P%n";
            if (!ShaOnly)
            {
                formatString +=
                    /* Tree                    */ "%T%n" +
                    /* Author Name             */ "%aN%n" +
                    /* Author Email            */ "%aE%n" +
                    /* Author Date             */ "%at%n" +
                    /* Committer Name          */ "%cN%n" +
                    /* Committer Date          */ "%ct%n" +
                    /* Commit message encoding */ "%e%n" + //there is a bug: git does not recode commit message when format is given
                    /* Commit Message          */ "%s";
            }

            // NOTE:
            // when called from FileHistory and FollowRenamesInFileHistory is enabled the "--name-only" argument is set.
            // the filename is the next line after the commit-format defined above.

            if (Settings.OrderRevisionByDate)
            {
                LogParam = " --date-order " + LogParam;
            }
            else
            {
                LogParam = " --topo-order " + LogParam;
            }

            string arguments = String.Format(CultureInfo.InvariantCulture,
                "log -z {2} --pretty=format:\"{1}\" {0}",
                LogParam,
                formatString,
                BranchFilter);

            using (GitCommandsInstance gitGetGraphCommand = new GitCommandsInstance(Module))
            {
                gitGetGraphCommand.StreamOutput = true;
                gitGetGraphCommand.CollectOutput = false;
                Encoding LogOutputEncoding = Module.LogOutputEncoding;
                gitGetGraphCommand.SetupStartInfoCallback = startInfo =>
                {
                    startInfo.StandardOutputEncoding = GitModule.LosslessEncoding;
                    startInfo.StandardErrorEncoding = GitModule.LosslessEncoding;
                };

                Process p = gitGetGraphCommand.CmdStartProcess(Settings.GitCommand, arguments);

                if (taskState.IsCanceled())
                    return;

                previousFileName = null;
                if (BeginUpdate != null)
                    BeginUpdate(this, EventArgs.Empty);

                string line;
                do
                {
                    line = p.StandardOutput.ReadLine();
                    //commit message is not encoded by git
                    if (nextStep != ReadStep.CommitMessage)
                        line = GitModule.ReEncodeString(line, GitModule.LosslessEncoding, LogOutputEncoding);

                    if (line != null)
                    {
                        foreach (string entry in line.Split('\0'))
                        {
                            dataReceived(entry);
                        }
                    }
                } while (line != null && !taskState.IsCanceled());

            }
        }
Пример #3
0
        private void execute(ILoadingTaskState taskState)
        {
            RevisionCount = 0;
            heads         = GetHeads().ToDictionaryOfList(head => head.Guid);

            string formatString =
                /* <COMMIT>       */ COMMIT_BEGIN + "%n" +
                /* Hash           */ "%H%n" +
                /* Parents        */ "%P%n";

            if (!ShaOnly)
            {
                formatString +=
                    /* Tree                    */ "%T%n" +
                    /* Author Name             */ "%aN%n" +
                    /* Author Email            */ "%aE%n" +
                    /* Author Date             */ "%at%n" +
                    /* Committer Name          */ "%cN%n" +
                    /* Committer Date          */ "%ct%n" +
                    /* Commit message encoding */ "%e%n" + //there is a bug: git does not recode commit message when format is given
                    /* Commit Message          */ "%s";
            }

            // NOTE:
            // when called from FileHistory and FollowRenamesInFileHistory is enabled the "--name-only" argument is set.
            // the filename is the next line after the commit-format defined above.

            if (Settings.OrderRevisionByDate)
            {
                LogParam = " --date-order " + LogParam;
            }
            else
            {
                LogParam = " --topo-order " + LogParam;
            }

            string arguments = String.Format(CultureInfo.InvariantCulture,
                                             "log -z {2} --pretty=format:\"{1}\" {0}",
                                             LogParam,
                                             formatString,
                                             BranchFilter);

            using (GitCommandsInstance gitGetGraphCommand = new GitCommandsInstance())
            {
                gitGetGraphCommand.StreamOutput  = true;
                gitGetGraphCommand.CollectOutput = false;
                Encoding LogOutputEncoding = Settings.LogOutputEncoding;
                gitGetGraphCommand.SetupStartInfoCallback = startInfo =>
                {
                    startInfo.StandardOutputEncoding = Settings.LosslessEncoding;
                    startInfo.StandardErrorEncoding  = Settings.LosslessEncoding;
                };

                Process p = gitGetGraphCommand.CmdStartProcess(Settings.GitCommand, arguments);

                if (taskState.IsCanceled())
                {
                    return;
                }

                previousFileName = null;
                if (BeginUpdate != null)
                {
                    BeginUpdate(this, EventArgs.Empty);
                }

                string line;
                do
                {
                    line = p.StandardOutput.ReadLine();
                    //commit message is not encoded by git
                    if (nextStep != ReadStep.CommitMessage)
                    {
                        line = GitCommandHelpers.ReEncodeString(line, Settings.LosslessEncoding, LogOutputEncoding);
                    }

                    if (line != null)
                    {
                        foreach (string entry in line.Split('\0'))
                        {
                            dataReceived(entry);
                        }
                    }
                } while (line != null && !taskState.IsCanceled());
            }
        }
Пример #4
0
        private void LoadModuleInfo(string command, string workingDir, ILoadingTaskState taskState)
        {
            using (GitCommandsInstance git = new GitCommandsInstance())
            {
                git.StreamOutput = true;
                git.CollectOutput = false;
                Process p = git.CmdStartProcess(Settings.GitCommand, command, workingDir);

                // Read line
                string line = p.StandardOutput.ReadLine();

                // Analyze commit listing
                while (!taskState.IsCanceled())
                {
                    Commit commit = new Commit();

                    // Reached the end ?
                    if (line == null)
                        break;

                    // Look for commit delimiters
                    if (!line.StartsWith("--- "))
                    {
                        line = p.StandardOutput.ReadLine();
                        continue;
                    }

                    // Strip "--- "
                    line = line.Substring(4);

                    // Split date and author
                    string[] header = line.Split(new string[] { " --- " }, 2, StringSplitOptions.RemoveEmptyEntries);
                    if (header.Length != 2)
                        continue;

                    // Save author in variable
                    commit.author = header[1];

                    // Parse commit date
                    DateTime date = DateTime.Parse(header[0]).Date;
                    // Calculate first day of the commit week
                    date = commit.week = date.AddDays(-(int)date.DayOfWeek);

                    // Reset commit data
                    commit.data.Commits = 1;
                    commit.data.AddedLines = 0;
                    commit.data.DeletedLines = 0;

                    // Parse commit lines
                    while ((line = p.StandardOutput.ReadLine()) != null && !line.StartsWith("--- ") && !taskState.IsCanceled())
                    {
                        // Skip empty line
                        if (string.IsNullOrEmpty(line))
                            continue;

                        string[] file_line = line.Split('\t');
                        if (file_line.Length >= 2)
                        {
                            if (file_line[0] != "-")
                                commit.data.AddedLines += int.Parse(file_line[0]);
                            if (file_line[1] != "-")
                                commit.data.DeletedLines += int.Parse(file_line[1]);
                        }
                    }

                    if (Updated != null && !taskState.IsCanceled())
                        Updated(commit);
                }
            }
        }
Пример #5
0
        private void execute(ILoadingTaskState taskState)
        {
            string authorName = this.RespectMailmap ? "%aN" : "%an";

            string command = "log --pretty=tformat:\"--- %ad --- " + authorName + "\" --numstat --date=iso -C --all --no-merges";

            LoadModuleInfo(command, GitModule.CurrentWorkingDir, taskState);

            if (ShowSubmodules)
            {
                IList<string> submodules = GitModule.Current.GetSubmodulesLocalPathes();
                foreach (var submoduleName in submodules)
                {
                    GitModule submodule = GitModule.Current.GetSubmodule(submoduleName);
                    if (submodule.ValidWorkingDir())
                        LoadModuleInfo(command, submodule.WorkingDir, taskState);
                }
            }
        }
Пример #6
0
        private void LoadModuleInfo(string command, string workingDir, ILoadingTaskState taskState)
        {
            using (GitCommandsInstance git = new GitCommandsInstance())
            {
                git.StreamOutput  = true;
                git.CollectOutput = false;
                Process p = git.CmdStartProcess(Settings.GitCommand, command, workingDir);

                // Read line
                string line = p.StandardOutput.ReadLine();

                // Analyze commit listing
                while (!taskState.IsCanceled())
                {
                    Commit commit = new Commit();

                    // Reached the end ?
                    if (line == null)
                    {
                        break;
                    }

                    // Look for commit delimiters
                    if (!line.StartsWith("--- "))
                    {
                        line = p.StandardOutput.ReadLine();
                        continue;
                    }

                    // Strip "--- "
                    line = line.Substring(4);

                    // Split date and author
                    string[] header = line.Split(new string[] { " --- " }, 2, StringSplitOptions.RemoveEmptyEntries);
                    if (header.Length != 2)
                    {
                        continue;
                    }

                    // Save author in variable
                    commit.author = header[1];

                    // Parse commit date
                    DateTime date = DateTime.Parse(header[0]).Date;
                    // Calculate first day of the commit week
                    date = commit.week = date.AddDays(-(int)date.DayOfWeek);

                    // Reset commit data
                    commit.data.Commits      = 1;
                    commit.data.AddedLines   = 0;
                    commit.data.DeletedLines = 0;

                    // Parse commit lines
                    while ((line = p.StandardOutput.ReadLine()) != null && !line.StartsWith("--- ") && !taskState.IsCanceled())
                    {
                        // Skip empty line
                        if (string.IsNullOrEmpty(line))
                        {
                            continue;
                        }

                        string[] file_line = line.Split('\t');
                        if (file_line.Length >= 2)
                        {
                            if (file_line[0] != "-")
                            {
                                commit.data.AddedLines += int.Parse(file_line[0]);
                            }
                            if (file_line[1] != "-")
                            {
                                commit.data.DeletedLines += int.Parse(file_line[1]);
                            }
                        }
                    }

                    if (Updated != null && !taskState.IsCanceled())
                    {
                        Updated(commit);
                    }
                }
            }
        }
Пример #7
0
        private void execute(ILoadingTaskState taskState)
        {
            string authorName = this.RespectMailmap ? "%aN" : "%an";

            string command = "log --pretty=tformat:\"--- %ad --- " + authorName + "\" --numstat --date=iso -C --all --no-merges";

            LoadModuleInfo(command, Settings.WorkingDir, taskState);

            if (ShowSubmodules)
            {
                IList<string> submodules = Settings.Module.GetSubmodulesNames();
                GitModule submodule = new GitModule();
                foreach (var submoduleName in submodules)
                {
                    submodule.WorkingDir = Settings.Module.WorkingDir + submoduleName +
                                           Settings.PathSeparator.ToString();
                    if (submodule.ValidWorkingDir())
                        LoadModuleInfo(command, submodule.WorkingDir, taskState);
                }
            }
        }