mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 05:05:00 +00:00
feature: add ${branch_name} option to commit templates (#589)
This commit is contained in:
parent
6dac26d525
commit
a8a7775b83
3 changed files with 8 additions and 4 deletions
|
@ -4,6 +4,7 @@ using System.Text;
|
|||
using System.Text.RegularExpressions;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using SourceGit.ViewModels;
|
||||
|
||||
namespace SourceGit.Models
|
||||
{
|
||||
|
@ -24,9 +25,12 @@ namespace SourceGit.Models
|
|||
set => SetProperty(ref _content, value);
|
||||
}
|
||||
|
||||
public string Apply(List<Change> changes)
|
||||
public string Apply(Repository repo, List<Change> changes)
|
||||
{
|
||||
var content = _content.Replace("${files_num}", $"{changes.Count}");
|
||||
var content = _content
|
||||
.Replace("${files_num}", $"{changes.Count}")
|
||||
.Replace("${branch_name}", repo.CurrentBranch.Name);
|
||||
|
||||
var matches = REG_COMMIT_TEMPLATE_FILES().Matches(content);
|
||||
if (matches.Count == 0)
|
||||
return content;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue