enhance: ignore untracked files when staging all changes with INCLUDE UNTRACKED FILES turned off (#577)

This commit is contained in:
leo 2024-10-20 18:32:05 +08:00
parent 7c253637fc
commit 45869c27b8
No known key found for this signature in database
2 changed files with 17 additions and 17 deletions

View file

@ -5,27 +5,27 @@ namespace SourceGit.Commands
{
public class Add : Command
{
public Add(string repo, List<Models.Change> changes = null)
public Add(string repo, bool includeUntracked)
{
WorkingDirectory = repo;
Context = repo;
Args = includeUntracked ? "add ." : "add -u .";
}
public Add(string repo, List<Models.Change> changes)
{
WorkingDirectory = repo;
Context = repo;
if (changes == null || changes.Count == 0)
var builder = new StringBuilder();
builder.Append("add --");
foreach (var c in changes)
{
Args = "add .";
}
else
{
var builder = new StringBuilder();
builder.Append("add --");
foreach (var c in changes)
{
builder.Append(" \"");
builder.Append(c.Path);
builder.Append("\"");
}
Args = builder.ToString();
builder.Append(" \"");
builder.Append(c.Path);
builder.Append("\"");
}
Args = builder.ToString();
}
}
}