Skip to content

Commit 990050d

Browse files
authored
Merge pull request #23 from ubisoft/misc-fixes
Misc fixes
2 parents 7dea52d + 4a32ff9 commit 990050d

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

GitTimelapseView.Core/Models/Commit.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void UpdateInfo(ILogger logger)
6464
var changes = repository.Diff.Compare<TreeChanges>(parents.FirstOrDefault()?.Tree, commit?.Tree);
6565
foreach (var change in changes)
6666
{
67-
_fileChanges.Add(new FileChange(this, change));
67+
_fileChanges.Add(new FileChange(this, change, repository.Info.WorkingDirectory));
6868
}
6969
}
7070

GitTimelapseView.Core/Models/FileChange.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ namespace GitTimelapseView.Core.Models
77
{
88
public sealed class FileChange
99
{
10-
public FileChange(Commit commit, TreeEntryChanges change)
10+
public FileChange(Commit commit, TreeEntryChanges change, string workingDirectory)
1111
{
1212
Commit = commit;
1313
ChangeKind = change.Status;
14-
Path = change.Path;
15-
OldPath = change.OldPath;
14+
Path = string.IsNullOrEmpty(change.Path) ? string.Empty : System.IO.Path.GetFullPath(System.IO.Path.Combine(workingDirectory, change.Path));
15+
OldPath = string.IsNullOrEmpty(change.OldPath) ? string.Empty : System.IO.Path.GetFullPath(System.IO.Path.Combine(workingDirectory, change.OldPath));
1616
Name = System.IO.Path.GetFileName(Path);
1717
}
1818

GitTimelapseView.Core/Models/FileHistory.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ public FileHistory(string filePath)
2020
FilePath = filePath;
2121
try
2222
{
23-
GitRootPath = Repository.Discover(filePath).Replace(@".git\", string.Empty, StringComparison.Ordinal);
23+
var repositoryPath = Repository.Discover(filePath);
24+
if (repositoryPath.Contains("\\.git\\modules\\", StringComparison.OrdinalIgnoreCase))
25+
GitRootPath = repositoryPath;
26+
else
27+
GitRootPath = repositoryPath.Replace(@".git\", string.Empty, StringComparison.Ordinal);
2428
}
2529
catch (Exception)
2630
{
@@ -112,7 +116,7 @@ private IReadOnlyList<FileCommitId> GetFileCommitIDs(ILogger logger)
112116

113117
if (commitIDs.Count > 1 && !isFirstTime)
114118
{
115-
commitIDs.RemoveAt(0);
119+
commitIDs.RemoveAt(commitIDs.Count - 1);
116120
}
117121

118122
commitIDs.AddRange(result.Select(x => new FileCommitId { Commit = x, FilePath = filePath }));

GitTimelapseView/Actions/DiffFileChangeAction.cs

+7-6
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@ public DiffFileChangeAction(FileChange fileChange, string commitId)
2525

2626
public override Task ExecuteAsync(IActionContext context)
2727
{
28-
context.TrackingProperties["Path"] = _fileChange.Path;
28+
var oldPath = _fileChange.OldPath;
29+
var path = _fileChange.Path;
30+
31+
context.TrackingProperties["Path"] = path;
2932
context.TrackingProperties["CommitId"] = _commitId;
3033

31-
context.LogInformation($"Diffing '{_fileChange.Path}' with commit '{_commitId}'");
32-
var oldPath = string.IsNullOrEmpty(_fileChange.OldPath) ? string.Empty : Path.GetFullPath(Path.Combine(_fileChange.Commit.FileHistory.GitRootPath, _fileChange.OldPath));
33-
var path = string.IsNullOrEmpty(_fileChange.Path) ? string.Empty : Path.GetFullPath(Path.Combine(_fileChange.Commit.FileHistory.GitRootPath, _fileChange.Path));
34+
context.LogInformation($"Diffing '{path}' with commit '{_commitId}'");
3435

35-
var errorMessage = $"Could not launch difftool on {_fileChange.Path} for commit {_commitId}";
36-
var args = path.Equals(oldPath, System.StringComparison.OrdinalIgnoreCase) ? $"difftool -y {_commitId}^ {_commitId} {path}".Trim(' ') : $"difftool -y {_commitId}^ {_commitId} {oldPath} {path}".Trim(' ');
36+
var errorMessage = $"Could not launch difftool on {path} for commit {_commitId}";
37+
var args = path.Equals(oldPath, StringComparison.OrdinalIgnoreCase) ? $"difftool -y {_commitId}^ {_commitId} {path}".Trim(' ') : $"difftool -y {_commitId}^ {_commitId} {oldPath} {path}".Trim(' ');
3738
GitHelpers.RunGitCommand(_fileChange.Commit.FileHistory.GitRootPath, args, context, errorMessage);
3839

3940
return Task.CompletedTask;

0 commit comments

Comments
 (0)