mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
feature: supports custom actions (#638)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
7c5de7e48c
commit
a36058ec51
17 changed files with 478 additions and 2 deletions
40
src/ViewModels/ExecuteCustomAction.cs
Normal file
40
src/ViewModels/ExecuteCustomAction.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class ExecuteCustomAction : Popup
|
||||
{
|
||||
public Models.CustomAction CustomAction
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ExecuteCustomAction(Repository repo, Models.CustomAction action, string sha)
|
||||
{
|
||||
_repo = repo;
|
||||
_args = action.Arguments.Replace("${REPO}", _repo.FullPath);
|
||||
if (!string.IsNullOrEmpty(sha))
|
||||
_args = _args.Replace("${SHA}", sha);
|
||||
|
||||
CustomAction = action;
|
||||
View = new Views.ExecuteCustomAction() { DataContext = this };
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = "Run custom action ...";
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
Commands.ExecuteCustomAction.Run(_repo.FullPath, CustomAction.Executable, _args, SetProgressDescription);
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private readonly Repository _repo = null;
|
||||
private string _args = string.Empty;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue