Пример #1
0
        public Change[] GetCommitDetail(string commitId)
        {
            var changes = new Change[0];

            using (var reader = ProcessUtils.ExecuteToStream(
                       DependencyContainer.Resolve <IAppConfiguration>().GitPath,
                       $"show --pretty=\"\" --name-status {commitId}",
                       DependencyContainer.Resolve <IAppConfiguration>().LocalGitDirectory))
            {
                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    var fields = line.SplitByChar('\t');
                    if (fields.Length >= 2)
                    {
                        if (fields[0].StartsWith("R", StringComparison.OrdinalIgnoreCase))
                        {
                            changes = changes.Append(new Change()
                            {
                                Action = "D",
                                Path   = fields[1],
                            }).Append(new Change()
                            {
                                Action = "A",
                                Path   = fields[2],
                            });
                        }
                        else if (fields[0] == "MM")
                        {
                            changes = changes.Append(new Change()
                            {
                                Action = "M",
                                Path   = fields[1],
                            });
                        }
                        else
                        {
                            changes = changes.Append(new Change()
                            {
                                Action = fields[0],
                                Path   = fields[1],
                            });
                        }
                    }
                }
            }

            return(changes);
        }