Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit ff60575

Browse files
committed
Use relativeOrGitPath when it doesn't matter
1 parent eec41c3 commit ff60575

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/GitHub.App/ViewModels/GitHubPane/PullRequestDirectoryNode.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using GitHub.Primitives;
45

56
namespace GitHub.ViewModels.GitHubPane
67
{
@@ -12,11 +13,11 @@ public class PullRequestDirectoryNode : IPullRequestDirectoryNode
1213
/// <summary>
1314
/// Initializes a new instance of the <see cref="PullRequestDirectoryNode"/> class.
1415
/// </summary>
15-
/// <param name="relativePath">The path to the directory, relative to the repository.</param>
16-
public PullRequestDirectoryNode(string relativePath)
16+
/// <param name="relativeOrGitPath">The path to the directory, relative to the repository.</param>
17+
public PullRequestDirectoryNode(string relativeOrGitPath)
1718
{
18-
DirectoryName = System.IO.Path.GetFileName(relativePath);
19-
RelativePath = relativePath.Replace("/", "\\");
19+
DirectoryName = System.IO.Path.GetFileName(relativeOrGitPath);
20+
RelativePath = Paths.ToRelativePath(relativeOrGitPath);
2021
Directories = new List<IPullRequestDirectoryNode>();
2122
Files = new List<IPullRequestFileNode>();
2223
}

src/GitHub.App/ViewModels/GitHubPane/PullRequestFileNode.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using GitHub.App;
44
using GitHub.Extensions;
55
using GitHub.Models;
6+
using GitHub.Primitives;
67
using ReactiveUI;
78

89
namespace GitHub.ViewModels.GitHubPane
@@ -21,7 +22,7 @@ public class PullRequestFileNode : ReactiveObject, IPullRequestFileNode
2122
/// Initializes a new instance of the <see cref="PullRequestFileNode"/> class.
2223
/// </summary>
2324
/// <param name="repositoryPath">The absolute path to the repository.</param>
24-
/// <param name="relativePath">The path to the file, relative to the repository.</param>
25+
/// <param name="relativeOrGitPath">The path to the file, relative to the repository.</param>
2526
/// <param name="sha">The SHA of the file.</param>
2627
/// <param name="status">The way the file was changed.</param>
2728
/// <param name="statusDisplay">The string to display in the [message] box next to the filename.</param>
@@ -31,17 +32,17 @@ public class PullRequestFileNode : ReactiveObject, IPullRequestFileNode
3132
/// </param>
3233
public PullRequestFileNode(
3334
string repositoryPath,
34-
string relativePath,
35+
string relativeOrGitPath,
3536
string sha,
3637
PullRequestFileStatus status,
3738
string oldPath)
3839
{
3940
Guard.ArgumentNotEmptyString(repositoryPath, nameof(repositoryPath));
40-
Guard.ArgumentNotEmptyString(relativePath, nameof(relativePath));
41+
Guard.ArgumentNotEmptyString(relativeOrGitPath, nameof(relativeOrGitPath));
4142
Guard.ArgumentNotEmptyString(sha, nameof(sha));
4243

43-
FileName = Path.GetFileName(relativePath);
44-
RelativePath = relativePath.Replace("/", "\\");
44+
FileName = Path.GetFileName(relativeOrGitPath);
45+
RelativePath = Paths.ToRelativePath(relativeOrGitPath);
4546
Sha = sha;
4647
Status = status;
4748
OldPath = oldPath;
@@ -54,7 +55,7 @@ public PullRequestFileNode(
5455
{
5556
if (oldPath != null)
5657
{
57-
StatusDisplay = Path.GetDirectoryName(oldPath) == Path.GetDirectoryName(relativePath) ?
58+
StatusDisplay = Path.GetDirectoryName(oldPath) == Path.GetDirectoryName(relativeOrGitPath) ?
5859
Path.GetFileName(oldPath) : oldPath;
5960
}
6061
else

0 commit comments

Comments
 (0)