diff --git a/src/Models/CustomAction.cs b/src/Models/CustomAction.cs
index 1ed65b8b..33d7e77e 100644
--- a/src/Models/CustomAction.cs
+++ b/src/Models/CustomAction.cs
@@ -9,6 +9,7 @@ namespace SourceGit.Models
Commit,
Branch,
Tag,
+ Remote,
}
public enum CustomActionControlType
diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index de16b5b7..ea7a338a 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -173,7 +173,7 @@
Template Name:
CUSTOM ACTION
Arguments:
- Built-in parameters: ${REPO} - repository's path; ${BRANCH} - selected branch; ${SHA} - selected commit's hash; ${TAG} - selected tag
+ Built-in parameters: ${REPO} - repository's path; ${REMOTE} - selected remote or selected branch's remote; ${BRANCH} - selected branch; ${SHA} - selected commit's hash; ${TAG} - selected tag
Executable File:
Input Controls:
Edit
@@ -182,6 +182,7 @@
Scope:
Branch
Commit
+ Remote
Repository
Tag
Wait for action exit
@@ -616,6 +617,7 @@
Repository URL:
Remote git repository URL
Copy URL
+ Custom Action
Delete...
Edit...
Fetch
diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml
index 15af237c..aeb6e040 100644
--- a/src/Resources/Locales/zh_CN.axaml
+++ b/src/Resources/Locales/zh_CN.axaml
@@ -177,7 +177,7 @@
模板名 :
自定义操作
命令行参数 :
- 内置变量:${REPO} 仓库路径、${BRANCH} 选中的分支、${SHA} 选中的提交哈希,${TAG} 选中的标签
+ 内置变量:${REPO} 仓库路径、${REMOTE} 选中的远程仓库或选中分支所属的远程仓库、${BRANCH} 选中的分支、${SHA} 选中的提交哈希,${TAG} 选中的标签
可执行文件路径 :
输入控件 :
编辑
@@ -186,6 +186,7 @@
作用目标 :
选中的分支
选中的提交
+ 远程仓库
仓库
选中的标签
等待操作执行完成
@@ -620,6 +621,7 @@
仓库地址 :
远程仓库的地址
复制远程地址
+ 自定义操作
删除 ...
编辑 ...
拉取(fetch)更新
diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml
index d217ac51..be23c8e0 100644
--- a/src/Resources/Locales/zh_TW.axaml
+++ b/src/Resources/Locales/zh_TW.axaml
@@ -177,7 +177,7 @@
範本名稱:
自訂動作
指令參數:
- 內建參數: ${REPO} 存放庫路徑、${BRANCH} 所選的分支、${SHA} 所選的提交編號、${TAG} 所選的標籤
+ 內建參數: ${REPO} 存放庫路徑、${REMOTE} 所選的遠端存放庫或所選分支的遠端、${BRANCH} 所選的分支、${SHA} 所選的提交編號、${TAG} 所選的標籤
可執行檔案路徑:
輸入控制項:
編輯
@@ -186,6 +186,7 @@
執行範圍:
選取的分支
選取的提交
+ 遠端存放庫
存放庫
選取的標籤
等待自訂動作執行結束
@@ -620,6 +621,7 @@
存放庫網址:
遠端存放庫的網址
複製遠端網址
+ 自訂動作
刪除...
編輯...
提取 (fetch) 更新
diff --git a/src/ViewModels/ExecuteCustomAction.cs b/src/ViewModels/ExecuteCustomAction.cs
index fb0f2f81..837259a7 100644
--- a/src/ViewModels/ExecuteCustomAction.cs
+++ b/src/ViewModels/ExecuteCustomAction.cs
@@ -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
};
}
diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs
index bd6d2c08..9ba559ca 100644
--- a/src/ViewModels/Repository.cs
+++ b/src/ViewModels/Repository.cs
@@ -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
diff --git a/src/Views/BranchTree.axaml.cs b/src/Views/BranchTree.axaml.cs
index 8c0b6310..8217b49f 100644
--- a/src/Views/BranchTree.axaml.cs
+++ b/src/Views/BranchTree.axaml.cs
@@ -940,6 +940,7 @@ namespace SourceGit.Views
menu.Items.Add(edit);
menu.Items.Add(delete);
menu.Items.Add(new MenuItem() { Header = "-" });
+ TryToAddCustomActionsToRemoteContextMenu(repo, menu, remote);
menu.Items.Add(copy);
return menu;
}
@@ -1112,6 +1113,35 @@ namespace SourceGit.Views
menu.Items.Add(new MenuItem() { Header = "-" });
}
+ private void TryToAddCustomActionsToRemoteContextMenu(ViewModels.Repository repo, ContextMenu menu, Models.Remote remote)
+ {
+ var actions = repo.GetCustomActions(Models.CustomActionScope.Remote);
+ if (actions.Count == 0)
+ return;
+
+ var custom = new MenuItem();
+ custom.Header = App.Text("RemoteCM.CustomAction");
+ custom.Icon = App.CreateMenuIcon("Icons.Action");
+
+ foreach (var action in actions)
+ {
+ var (dup, label) = action;
+ var item = new MenuItem();
+ item.Icon = App.CreateMenuIcon("Icons.Action");
+ item.Header = label;
+ item.Click += async (_, e) =>
+ {
+ await repo.ExecCustomActionAsync(dup, remote);
+ e.Handled = true;
+ };
+
+ custom.Items.Add(item);
+ }
+
+ menu.Items.Add(custom);
+ menu.Items.Add(new MenuItem() { Header = "-" });
+ }
+
private bool _disableSelectionChangingEvent = false;
}
}
diff --git a/src/Views/ExecuteCustomAction.axaml b/src/Views/ExecuteCustomAction.axaml
index 4f0c6c6d..5329794f 100644
--- a/src/Views/ExecuteCustomAction.axaml
+++ b/src/Views/ExecuteCustomAction.axaml
@@ -50,6 +50,13 @@
+
+
+
+
+
+
+
diff --git a/src/Views/Preferences.axaml b/src/Views/Preferences.axaml
index a01b1080..90df4323 100644
--- a/src/Views/Preferences.axaml
+++ b/src/Views/Preferences.axaml
@@ -656,6 +656,7 @@
+
diff --git a/src/Views/RepositoryConfigure.axaml b/src/Views/RepositoryConfigure.axaml
index a99b717f..14dc3bc1 100644
--- a/src/Views/RepositoryConfigure.axaml
+++ b/src/Views/RepositoryConfigure.axaml
@@ -480,6 +480,7 @@
+