mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 19:55:00 +00:00
47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System.IO;
|
|
|
|
namespace SourceGit.Commands {
|
|
|
|
/// <summary>
|
|
/// 标签相关指令
|
|
/// </summary>
|
|
public class Tag : Command {
|
|
|
|
public Tag(string repo) {
|
|
Cwd = repo;
|
|
}
|
|
|
|
public bool Add(string name, string basedOn, string message) {
|
|
Args = $"tag -a {name} {basedOn} ";
|
|
|
|
if (!string.IsNullOrEmpty(message)) {
|
|
string tmp = Path.GetTempFileName();
|
|
File.WriteAllText(tmp, message);
|
|
Args += $"-F \"{tmp}\"";
|
|
} else {
|
|
Args += $"-m {name}";
|
|
}
|
|
|
|
return Exec();
|
|
}
|
|
|
|
public bool Delete(string name, bool push) {
|
|
Args = $"tag --delete {name}";
|
|
if (!Exec()) return false;
|
|
|
|
var repo = Models.Preference.Instance.FindRepository(Cwd);
|
|
if (repo != null && repo.Filters.Contains(name)) {
|
|
repo.Filters.Remove(name);
|
|
}
|
|
|
|
if (push) {
|
|
var remotes = new Remotes(Cwd).Result();
|
|
foreach (var r in remotes) {
|
|
new Push(Cwd, r.Name, name, true).Exec();
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|