コード例 #1
0
        public Commit[] GetTotalCommits()
        {
            var config = DependencyContainer.Resolve <IAppConfiguration>();

            var commits = new Commit[0];

            using (var reader = ProcessUtils.ExecuteToStream(
                       DependencyContainer.Resolve <IAppConfiguration>().GitPath,
                       $"log --after \"{config.StartTime.ToString("yyyy-MM-dd HH:mm:ss")}\" --before \"{(config.EndTime ?? DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss")}\" --pretty=format:\"%H|%cI|%an|%s\" {config.BranchName}",
                       DependencyContainer.Resolve <IAppConfiguration>().LocalGitDirectory))
            {
                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    var fields = line.SplitByChar('|');
                    if (fields.Length >= 4)
                    {
                        commits = commits.Append(new Commit()
                        {
                            Id      = fields[0],
                            Date    = DateTime.Parse(fields[1]),
                            Author  = fields[2],
                            Subject = string.Join("|", fields.Skip(3)),
                        });
                    }
                }
            }

            return(commits);
        }