Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bording committed Nov 24, 2024
1 parent 08fafd5 commit f145a2c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
16 changes: 6 additions & 10 deletions LibGit2Sharp.Tests/WorktreeFixture.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -289,10 +288,10 @@ 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);

Assert.Equal(filesInMain, filesInBranch);
}
}
Expand All @@ -314,7 +313,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);
Expand Down Expand Up @@ -351,7 +349,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);
Expand Down Expand Up @@ -380,7 +377,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);
Expand All @@ -390,9 +386,9 @@ public void CanAddWorktreeForCommittish()
private static IEnumerable<string> 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(Path.Combine(repoPath, ".git")))
.Select(fileName => fileName.Replace($"{repoPath}{Path.DirectorySeparatorChar}", ""))
.OrderBy(fileName => fileName)
.ToList();
}
}
Expand Down
8 changes: 4 additions & 4 deletions LibGit2Sharp/WorktreeCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public virtual Worktree this[string name]
}

/// <summary>
///
/// Creates a worktree.
/// </summary>
/// <param name="committishOrBranchSpec">A committish or branch name./param>
/// <param name="committishOrBranchSpec">The committish to checkout into the new worktree.</param>
/// <param name="name">Name of the worktree.</param>
/// <param name="path">Location of the worktree.</param>
/// <param name="isLocked"></param>
Expand Down Expand Up @@ -84,11 +84,11 @@ public virtual Worktree Add(string committishOrBranchSpec, string name, string p
}

/// <summary>
///
/// Creates a worktree.
/// </summary>
/// <param name="committishOrBranchSpec">A committish or branch name./param>
/// <param name="name">Name of the worktree.</param>
/// <param name="path">Location of the worktree.</param>
/// <param name="isLocked"></param>
public virtual Worktree Add(string name, string path, bool isLocked)
{
var options = new git_worktree_add_options
Expand Down

0 comments on commit f145a2c

Please sign in to comment.