From 728d0037179b7415345c170e87837d244f92c420 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 22 Oct 2024 10:06:53 +0800 Subject: [PATCH] code_review: PR #589 * do not using namespace `SourceGit.*` * should use branch instead of repository --- src/Models/CommitTemplate.cs | 5 ++--- src/ViewModels/WorkingCopy.cs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Models/CommitTemplate.cs b/src/Models/CommitTemplate.cs index ba9a4911..b34fa5a5 100644 --- a/src/Models/CommitTemplate.cs +++ b/src/Models/CommitTemplate.cs @@ -4,7 +4,6 @@ using System.Text; using System.Text.RegularExpressions; using CommunityToolkit.Mvvm.ComponentModel; -using SourceGit.ViewModels; namespace SourceGit.Models { @@ -25,11 +24,11 @@ namespace SourceGit.Models set => SetProperty(ref _content, value); } - public string Apply(Repository repo, List changes) + public string Apply(Branch branch, List changes) { var content = _content .Replace("${files_num}", $"{changes.Count}") - .Replace("${branch_name}", repo.CurrentBranch.Name); + .Replace("${branch_name}", branch.Name); var matches = REG_COMMIT_TEMPLATE_FILES().Matches(content); if (matches.Count == 0) diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 808a7ef6..b5da419f 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -1157,7 +1157,7 @@ namespace SourceGit.ViewModels item.Icon = App.CreateMenuIcon("Icons.Code"); item.Click += (_, e) => { - CommitMessage = template.Apply(_repo, _staged); + CommitMessage = template.Apply(_repo.CurrentBranch, _staged); e.Handled = true; }; menu.Items.Add(item);