Files
sourcegit/src/ViewModels/PushRevision.cs

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;
}
}