Skip to content

Commit f145a2c

Browse files
committedNov 24, 2024
Tweaks
1 parent 08fafd5 commit f145a2c

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed
 

‎LibGit2Sharp.Tests/WorktreeFixture.cs

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using LibGit2Sharp.Tests.TestHelpers;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.IO;
54
using System.Linq;
5+
using LibGit2Sharp.Tests.TestHelpers;
66
using Xunit;
77

88
namespace LibGit2Sharp.Tests
@@ -252,7 +252,6 @@ public void CanAddWorktree_WithUncommitedChanges()
252252
Assert.Equal(3, repo.Worktrees.Count());
253253

254254
// Check that branch contains same number of files and folders
255-
// NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com/libgit2/libgit2sharp/issues/2037)
256255
Assert.True(repo.RetrieveStatus().IsDirty);
257256
var filesInMain = GetFilesOfRepo(repoPath);
258257
var filesInBranch = GetFilesOfRepo(path);
@@ -289,10 +288,10 @@ public void CanAddWorktree_WithCommitedChanges()
289288
Assert.Equal(3, repo.Worktrees.Count());
290289

291290
// Check that branch contains same number of files and folders
292-
// NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com/libgit2/libgit2sharp/issues/2037)
293291
Assert.False(repo.RetrieveStatus().IsDirty);
294292
var filesInMain = GetFilesOfRepo(repoPath);
295293
var filesInBranch = GetFilesOfRepo(path);
294+
296295
Assert.Equal(filesInMain, filesInBranch);
297296
}
298297
}
@@ -314,7 +313,6 @@ public void CanAddLockedWorktree_WithUncommitedChanges()
314313
Assert.Equal(3, repo.Worktrees.Count());
315314

316315
// Check that branch contains same number of files and folders
317-
// NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com/libgit2/libgit2sharp/issues/2037)
318316
Assert.True(repo.RetrieveStatus().IsDirty);
319317
var filesInMain = GetFilesOfRepo(repoPath);
320318
var filesInBranch = GetFilesOfRepo(path);
@@ -351,7 +349,6 @@ public void CanAddLockedWorktree_WithCommitedChanges()
351349
Assert.Equal(3, repo.Worktrees.Count());
352350

353351
// Check that branch contains same number of files and folders
354-
// NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com/libgit2/libgit2sharp/issues/2037)
355352
Assert.False(repo.RetrieveStatus().IsDirty);
356353
var filesInMain = GetFilesOfRepo(repoPath);
357354
var filesInBranch = GetFilesOfRepo(path);
@@ -380,7 +377,6 @@ public void CanAddWorktreeForCommittish()
380377
Assert.Equal(3, repo.Worktrees.Count());
381378

382379
// Check that branch contains same number of files and folders
383-
// NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com/libgit2/libgit2sharp/issues/2037)
384380
var filesInCommittish = new string[] { "numbers.txt", "super-file.txt" };
385381
var filesInBranch = GetFilesOfRepo(path);
386382
Assert.Equal(filesInCommittish, filesInBranch);
@@ -390,9 +386,9 @@ public void CanAddWorktreeForCommittish()
390386
private static IEnumerable<string> GetFilesOfRepo(string repoPath)
391387
{
392388
return Directory.GetFiles(repoPath, "*", SearchOption.AllDirectories)
393-
.Where(fileName => !fileName.StartsWith($"{repoPath}\\.git", StringComparison.InvariantCultureIgnoreCase))
394-
.Select(fileName => fileName.Replace($"{repoPath}\\", "", StringComparison.InvariantCultureIgnoreCase))
395-
.OrderBy(fileName => fileName, StringComparer.InvariantCultureIgnoreCase)
389+
.Where(fileName => !fileName.StartsWith(Path.Combine(repoPath, ".git")))
390+
.Select(fileName => fileName.Replace($"{repoPath}{Path.DirectorySeparatorChar}", ""))
391+
.OrderBy(fileName => fileName)
396392
.ToList();
397393
}
398394
}

‎LibGit2Sharp/WorktreeCollection.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public virtual Worktree this[string name]
4646
}
4747

4848
/// <summary>
49-
///
49+
/// Creates a worktree.
5050
/// </summary>
51-
/// <param name="committishOrBranchSpec">A committish or branch name./param>
51+
/// <param name="committishOrBranchSpec">The committish to checkout into the new worktree.</param>
5252
/// <param name="name">Name of the worktree.</param>
5353
/// <param name="path">Location of the worktree.</param>
5454
/// <param name="isLocked"></param>
@@ -84,11 +84,11 @@ public virtual Worktree Add(string committishOrBranchSpec, string name, string p
8484
}
8585

8686
/// <summary>
87-
///
87+
/// Creates a worktree.
8888
/// </summary>
89-
/// <param name="committishOrBranchSpec">A committish or branch name./param>
9089
/// <param name="name">Name of the worktree.</param>
9190
/// <param name="path">Location of the worktree.</param>
91+
/// <param name="isLocked"></param>
9292
public virtual Worktree Add(string name, string path, bool isLocked)
9393
{
9494
var options = new git_worktree_add_options

0 commit comments

Comments
 (0)
Failed to load comments.