2024-02-05 23:08:37 -08:00
|
|
|
|
using System.Collections.Generic;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
namespace SourceGit.Commands
|
|
|
|
|
{
|
|
|
|
|
public class Add : Command
|
|
|
|
|
{
|
|
|
|
|
public Add(string repo, List<Models.Change> changes = null)
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
WorkingDirectory = repo;
|
|
|
|
|
Context = repo;
|
2021-04-29 05:05:55 -07:00
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
if (changes == null || changes.Count == 0)
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
Args = "add .";
|
2024-03-17 18:37:06 -07:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
var builder = new StringBuilder();
|
|
|
|
|
builder.Append("add --");
|
2024-03-17 18:37:06 -07:00
|
|
|
|
foreach (var c in changes)
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
builder.Append(" \"");
|
|
|
|
|
builder.Append(c.Path);
|
|
|
|
|
builder.Append("\"");
|
|
|
|
|
}
|
|
|
|
|
Args = builder.ToString();
|
2021-04-29 05:05:55 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|