mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-26 03:40:45 +08:00
60 lines
1.4 KiB
C#
60 lines
1.4 KiB
C#
using System.Threading.Tasks;
|
|
|
|
namespace SourceGit.ViewModels
|
|
{
|
|
public class PushRevision : Popup
|
|
{
|
|
public Models.Commit Revision
|
|
{
|
|
get;
|
|
}
|
|
|
|
public Models.Branch RemoteBranch
|
|
{
|
|
get;
|
|
}
|
|
|
|
public bool Force
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
public PushRevision(Repository repo, Models.Commit revision, Models.Branch remoteBranch)
|
|
{
|
|
_repo = repo;
|
|
Revision = revision;
|
|
RemoteBranch = remoteBranch;
|
|
Force = false;
|
|
}
|
|
|
|
public override Task<bool> Sure()
|
|
{
|
|
_repo.SetWatcherEnabled(false);
|
|
ProgressDescription = $"Push {Revision.SHA.Substring(0, 10)} -> {RemoteBranch.FriendlyName} ...";
|
|
|
|
var log = _repo.CreateLog("Push Revision");
|
|
Use(log);
|
|
|
|
return Task.Run(() =>
|
|
{
|
|
var succ = new Commands.Push(
|
|
_repo.FullPath,
|
|
Revision.SHA,
|
|
RemoteBranch.Remote,
|
|
RemoteBranch.Name,
|
|
false,
|
|
false,
|
|
false,
|
|
Force).Use(log).Exec();
|
|
|
|
log.Complete();
|
|
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
|
return succ;
|
|
});
|
|
}
|
|
|
|
private readonly Repository _repo;
|
|
}
|
|
}
|