From b264cf6a3e54a540e273588683c6ef4cf51b159c Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sun, 24 Nov 2024 02:48:19 -0500 Subject: [PATCH] Tweaks --- LibGit2Sharp.Tests/WorktreeFixture.cs | 15 +++++---------- LibGit2Sharp/WorktreeCollection.cs | 8 ++++---- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/LibGit2Sharp.Tests/WorktreeFixture.cs b/LibGit2Sharp.Tests/WorktreeFixture.cs index e51a79942..f6259a12f 100644 --- a/LibGit2Sharp.Tests/WorktreeFixture.cs +++ b/LibGit2Sharp.Tests/WorktreeFixture.cs @@ -1,8 +1,8 @@ -using LibGit2Sharp.Tests.TestHelpers; -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; +using LibGit2Sharp.Tests.TestHelpers; using Xunit; namespace LibGit2Sharp.Tests @@ -252,7 +252,6 @@ public void CanAddWorktree_WithUncommitedChanges() Assert.Equal(3, repo.Worktrees.Count()); // Check that branch contains same number of files and folders - // NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com/libgit2/libgit2sharp/issues/2037) Assert.True(repo.RetrieveStatus().IsDirty); var filesInMain = GetFilesOfRepo(repoPath); var filesInBranch = GetFilesOfRepo(path); @@ -289,7 +288,6 @@ public void CanAddWorktree_WithCommitedChanges() Assert.Equal(3, repo.Worktrees.Count()); // Check that branch contains same number of files and folders - // NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com/libgit2/libgit2sharp/issues/2037) Assert.False(repo.RetrieveStatus().IsDirty); var filesInMain = GetFilesOfRepo(repoPath); var filesInBranch = GetFilesOfRepo(path); @@ -314,7 +312,6 @@ public void CanAddLockedWorktree_WithUncommitedChanges() Assert.Equal(3, repo.Worktrees.Count()); // Check that branch contains same number of files and folders - // NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com/libgit2/libgit2sharp/issues/2037) Assert.True(repo.RetrieveStatus().IsDirty); var filesInMain = GetFilesOfRepo(repoPath); var filesInBranch = GetFilesOfRepo(path); @@ -351,7 +348,6 @@ public void CanAddLockedWorktree_WithCommitedChanges() Assert.Equal(3, repo.Worktrees.Count()); // Check that branch contains same number of files and folders - // NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com/libgit2/libgit2sharp/issues/2037) Assert.False(repo.RetrieveStatus().IsDirty); var filesInMain = GetFilesOfRepo(repoPath); var filesInBranch = GetFilesOfRepo(path); @@ -380,7 +376,6 @@ public void CanAddWorktreeForCommittish() Assert.Equal(3, repo.Worktrees.Count()); // Check that branch contains same number of files and folders - // NOTE: There is an open bug - [Repository.Worktrees.Add leaves now worktree empty](https://github.com/libgit2/libgit2sharp/issues/2037) var filesInCommittish = new string[] { "numbers.txt", "super-file.txt" }; var filesInBranch = GetFilesOfRepo(path); Assert.Equal(filesInCommittish, filesInBranch); @@ -390,9 +385,9 @@ public void CanAddWorktreeForCommittish() private static IEnumerable GetFilesOfRepo(string repoPath) { return Directory.GetFiles(repoPath, "*", SearchOption.AllDirectories) - .Where(fileName => !fileName.StartsWith($"{repoPath}\\.git", StringComparison.InvariantCultureIgnoreCase)) - .Select(fileName => fileName.Replace($"{repoPath}\\", "", StringComparison.InvariantCultureIgnoreCase)) - .OrderBy(fileName => fileName, StringComparer.InvariantCultureIgnoreCase) + .Where(fileName => !fileName.StartsWith($"{repoPath}\\.git")) + .Select(fileName => fileName.Replace($"{repoPath}\\", "")) + .OrderBy(fileName => fileName) .ToList(); } } diff --git a/LibGit2Sharp/WorktreeCollection.cs b/LibGit2Sharp/WorktreeCollection.cs index b79623c4c..d99e11d7a 100644 --- a/LibGit2Sharp/WorktreeCollection.cs +++ b/LibGit2Sharp/WorktreeCollection.cs @@ -46,9 +46,9 @@ public virtual Worktree this[string name] } /// - /// + /// Creates a worktree. /// - /// A committish or branch name./param> + /// The committish to checkout into the new worktree. /// Name of the worktree. /// Location of the worktree. /// @@ -84,11 +84,11 @@ public virtual Worktree Add(string committishOrBranchSpec, string name, string p } /// - /// + /// Creates a worktree. /// - /// A committish or branch name./param> /// Name of the worktree. /// Location of the worktree. + /// public virtual Worktree Add(string name, string path, bool isLocked) { var options = new git_worktree_add_options