Skip to content

Commit d577e33

Browse files
committed
feat: add Built-in parameters: DIRNAME, Fixes sourcegit-scm#1628
1 parent ad95a19 commit d577e33

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

src/Resources/Locales/en_US.axaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,10 @@
175175
<x:String x:Key="Text.Configure.CommitMessageTemplate.Name" xml:space="preserve">Template Name:</x:String>
176176
<x:String x:Key="Text.Configure.CustomAction" xml:space="preserve">CUSTOM ACTION</x:String>
177177
<x:String x:Key="Text.Configure.CustomAction.Arguments" xml:space="preserve">Arguments:</x:String>
178-
<x:String x:Key="Text.Configure.CustomAction.Arguments.Tip" xml:space="preserve">Built-in parameters:
179-
178+
<x:String x:Key="Text.Configure.CustomAction.Arguments.Tip" xml:space="preserve">Built-in parameters:
179+
180180
${REPO} Repository's path
181+
${DIRNAME} - repository's directory name;
181182
${REMOTE} Selected remote or selected branch's remote
182183
${BRANCH} Selected branch, without ${REMOTE} part for remote branches
183184
${BRANCH_FRIENDLY_NAME} Friendly name of selected branch, contains ${REMOTE} part for remote branches

src/Resources/Locales/zh_CN.axaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@
180180
<x:String x:Key="Text.Configure.CustomAction" xml:space="preserve">自定义操作</x:String>
181181
<x:String x:Key="Text.Configure.CustomAction.Arguments" xml:space="preserve">命令行参数 :</x:String>
182182
<x:String x:Key="Text.Configure.CustomAction.Arguments.Tip" xml:space="preserve">内置变量:
183-
183+
184184
${REPO} 仓库路径
185+
${DIRNAME} 仓库文件夹名
185186
${REMOTE} 选中的远程仓库或选中分支所属的远程仓库
186187
${BRANCH} 选中的分支,对于远程分支不包含远程名
187188
${BRANCH_FRIENDLY_NAME} 选中的分支,对于远程分支包含远程名

src/Resources/Locales/zh_TW.axaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,10 @@
179179
<x:String x:Key="Text.Configure.CommitMessageTemplate.Name" xml:space="preserve">範本名稱:</x:String>
180180
<x:String x:Key="Text.Configure.CustomAction" xml:space="preserve">自訂動作</x:String>
181181
<x:String x:Key="Text.Configure.CustomAction.Arguments" xml:space="preserve">指令參數:</x:String>
182-
<x:String x:Key="Text.Configure.CustomAction.Arguments.Tip" xml:space="preserve">內建參數:
183-
182+
<x:String x:Key="Text.Configure.CustomAction.Arguments.Tip" xml:space="preserve">內建參數:
183+
184184
${REPO} 存放庫路徑
185+
${DIRNAME} 存放庫資料夾名
185186
${REMOTE} 所選的遠端存放庫或所選分支的遠端
186187
${BRANCH} 所選的分支。對於遠端分支,不包含遠端名稱
187188
${BRANCH_FRIENDLY_NAME} 所選的分支。對於遠端分支,不包含遠端名稱

src/ViewModels/ExecuteCustomAction.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ private void PrepareControlParameters()
179179
private string PrepareStringByTarget(string org)
180180
{
181181
org = org.Replace("${REPO}", GetWorkdir());
182+
org = org.Replace("${DIRNAME}", GetWorkdirname());
182183

183184
return Target switch
184185
{
@@ -195,6 +196,11 @@ private string GetWorkdir()
195196
return OperatingSystem.IsWindows() ? _repo.FullPath.Replace("/", "\\") : _repo.FullPath;
196197
}
197198

199+
private string GetWorkdirname()
200+
{
201+
return _repo.FullPath.Replace("\\", "/").Split('/')[^1];
202+
}
203+
198204
private void Run(string args)
199205
{
200206
var start = new ProcessStartInfo();

0 commit comments

Comments
 (0)