mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 21:54:59 +00:00

* use `--pathspec-from-file=<FILE>` in `git add` command if git >= 2.25.0 * use `--pathspec-from-file=<FILE>` in `git stash push` command if git >= 2.26.0 * use `--staged` in `git stash push` command only if git >= 2.35.0
38 lines
1,003 B
C#
38 lines
1,003 B
C#
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace SourceGit.Commands
|
|
{
|
|
public class Add : Command
|
|
{
|
|
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;
|
|
|
|
var builder = new StringBuilder();
|
|
builder.Append("add --");
|
|
foreach (var c in changes)
|
|
{
|
|
builder.Append(" \"");
|
|
builder.Append(c.Path);
|
|
builder.Append("\"");
|
|
}
|
|
Args = builder.ToString();
|
|
}
|
|
|
|
public Add(string repo, string pathspecFromFile)
|
|
{
|
|
WorkingDirectory = repo;
|
|
Context = repo;
|
|
Args = $"add --pathspec-from-file=\"{pathspecFromFile}\"";
|
|
}
|
|
}
|
|
}
|