diff --git a/Logic/Commit.cs b/Logic/Commit.cs index a8bd833..0026242 100644 --- a/Logic/Commit.cs +++ b/Logic/Commit.cs @@ -1,4 +1,6 @@ -namespace GitViz.Logic +using System; + +namespace GitViz.Logic { public class Commit { @@ -8,15 +10,17 @@ public class Commit public string[] Refs { get; set; } - public long CommitDate { get; set; } - + public string CommitterEmail { get; set; } + + public DateTime CommitDate { get; set; } + public string Subject { get; set; } public string ShortHash { get { return Hash.Substring(0, 7); } - } - - + } + + } } diff --git a/Logic/LogParser.cs b/Logic/LogParser.cs index a24c9c1..207a050 100644 --- a/Logic/LogParser.cs +++ b/Logic/LogParser.cs @@ -8,7 +8,7 @@ namespace GitViz.Logic { public class LogParser { - public readonly string ExpectedOutputFormat = "%ct %H %P %d %s"; + public readonly string ExpectedOutputFormat = "%ct %ce %H %P %d %s"; public IEnumerable ParseCommits(StreamReader gitLogOutput) { @@ -19,9 +19,9 @@ public IEnumerable ParseCommits(StreamReader gitLogOutput) yield return ParseCommit(line); } gitLogOutput.Close(); - } - - static readonly Regex ParseCommitRegex = new Regex(@"^(?\d*) (?\w{7,40})(?( \w{7,40})+)?([ ]+\((?.*?)\))?\s?((?.*))?"); + } + + static readonly Regex ParseCommitRegex = new Regex(@"^(?\d*) (?.+@[^ ]+) (?\w{7,40})(?( \w{7,40})+)?([ ]+\((?.*?)\))?\s?((?.*))?"); internal static Commit ParseCommit(string logOutputLine) { @@ -39,20 +39,27 @@ internal static Commit ParseCommit(string logOutputLine) .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(r => r.Trim()) .ToArray() - : null; - - var subject = match.Groups["subject"].Success - ? match.Groups["subject"].Value + : null; + + var subject = match.Groups["subject"].Success + ? match.Groups["subject"].Value : null; return new Commit { Hash = match.Groups["hash"].Value, - CommitDate = commitDate, + CommitDate = ConvertUnixTimeToLocalTime(commitDate), + CommitterEmail = match.Groups["committerEmail"].Value, ParentHashes = parentHashes, Refs = refs, Subject = subject, }; } + + private static DateTime ConvertUnixTimeToLocalTime(long unixTime) + { + var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + return dateTime.AddSeconds(unixTime).ToLocalTime(); + } } } diff --git a/Logic/ViewModel.cs b/Logic/ViewModel.cs index 7289ec4..60dc197 100644 --- a/Logic/ViewModel.cs +++ b/Logic/ViewModel.cs @@ -48,7 +48,7 @@ public string RepositoryPath get { return _repositoryPath; } set { - _repositoryPath = value; + _repositoryPath = value.Trim(); if (IsValidGitRepository(_repositoryPath)) { commandExecutor = new GitCommandExecutor(_repositoryPath); @@ -205,6 +205,32 @@ public Int32 NumOfCommitsToShow } private Int32 _numOfCommitsToShow; + public bool VisualizeCommitDate + { + get { return _visualizeCommitDate; } + set + { + _visualizeCommitDate = value; + if (logRetriever != null) RefreshGraph(logRetriever); //TODO: Refactor. + OnPropertyChanged("VisualizeCommitDate"); + } + } + + private bool _visualizeCommitDate; + + public bool VisualizeCommitterEmail + { + get { return _visualizeCommitterEmail; } + set + { + _visualizeCommitterEmail = value; + if (logRetriever != null) RefreshGraph(logRetriever); //TODO: Refactor. + OnPropertyChanged("VisualizeCommitterEmail"); + } + } + + private bool _visualizeCommitterEmail; + static bool IsValidGitRepository(string path) { return !string.IsNullOrEmpty(path) diff --git a/UI/MainWindow.xaml b/UI/MainWindow.xaml index dab4c8d..5e1b2f5 100644 --- a/UI/MainWindow.xaml +++ b/UI/MainWindow.xaml @@ -15,10 +15,17 @@ - - + + + + + + + + @@ -82,7 +89,9 @@ - + + +