mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-30 13:51:53 +08:00
feature: support creating custom action for selected remote (#1726)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -119,35 +119,11 @@ namespace SourceGit.ViewModels
|
||||
get;
|
||||
} = [];
|
||||
|
||||
public ExecuteCustomAction(Repository repo, Models.CustomAction action)
|
||||
public ExecuteCustomAction(Repository repo, Models.CustomAction action, object scopeTarget)
|
||||
{
|
||||
_repo = repo;
|
||||
CustomAction = action;
|
||||
Target = new Models.Null();
|
||||
PrepareControlParameters();
|
||||
}
|
||||
|
||||
public ExecuteCustomAction(Repository repo, Models.CustomAction action, Models.Branch branch)
|
||||
{
|
||||
_repo = repo;
|
||||
CustomAction = action;
|
||||
Target = branch;
|
||||
PrepareControlParameters();
|
||||
}
|
||||
|
||||
public ExecuteCustomAction(Repository repo, Models.CustomAction action, Models.Commit commit)
|
||||
{
|
||||
_repo = repo;
|
||||
CustomAction = action;
|
||||
Target = commit;
|
||||
PrepareControlParameters();
|
||||
}
|
||||
|
||||
public ExecuteCustomAction(Repository repo, Models.CustomAction action, Models.Tag tag)
|
||||
{
|
||||
_repo = repo;
|
||||
CustomAction = action;
|
||||
Target = tag;
|
||||
Target = scopeTarget ?? new Models.Null();
|
||||
PrepareControlParameters();
|
||||
}
|
||||
|
||||
@@ -206,9 +182,10 @@ namespace SourceGit.ViewModels
|
||||
|
||||
return Target switch
|
||||
{
|
||||
Models.Branch b => org.Replace("${BRANCH}", b.FriendlyName),
|
||||
Models.Branch b => org.Replace("${BRANCH}", b.FriendlyName).Replace("${REMOTE}", b.Remote),
|
||||
Models.Commit c => org.Replace("${SHA}", c.SHA),
|
||||
Models.Tag t => org.Replace("${TAG}", t.Name),
|
||||
Models.Remote r => org.Replace("${REMOTE}", r.Name),
|
||||
_ => org
|
||||
};
|
||||
}
|
||||
|
||||
@@ -876,19 +876,12 @@ namespace SourceGit.ViewModels
|
||||
ShowPopup(new Apply(this));
|
||||
}
|
||||
|
||||
public async Task ExecCustomActionAsync(Models.CustomAction action, object scope)
|
||||
public async Task ExecCustomActionAsync(Models.CustomAction action, object scopeTarget)
|
||||
{
|
||||
if (!CanCreatePopup())
|
||||
return;
|
||||
|
||||
var popup = scope switch
|
||||
{
|
||||
Models.Branch b => new ExecuteCustomAction(this, action, b),
|
||||
Models.Commit c => new ExecuteCustomAction(this, action, c),
|
||||
Models.Tag t => new ExecuteCustomAction(this, action, t),
|
||||
_ => new ExecuteCustomAction(this, action)
|
||||
};
|
||||
|
||||
var popup = new ExecuteCustomAction(this, action, scopeTarget);
|
||||
if (action.Controls.Count == 0)
|
||||
await ShowAndStartPopupAsync(popup);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user