Skip to content

Commit

Permalink
code_review: PR #589
Browse files Browse the repository at this point in the history
* do not using namespace `SourceGit.*`
* should use branch instead of repository
  • Loading branch information
love-linger committed Oct 22, 2024
1 parent 1855b43 commit 728d003
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/Models/CommitTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Text.RegularExpressions;

using CommunityToolkit.Mvvm.ComponentModel;
using SourceGit.ViewModels;

namespace SourceGit.Models
{
Expand All @@ -25,11 +24,11 @@ public string Content
set => SetProperty(ref _content, value);
}

public string Apply(Repository repo, List<Change> changes)
public string Apply(Branch branch, List<Change> 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)
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/WorkingCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ public ContextMenu CreateContextMenuForCommitMessages()
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);
Expand Down

0 comments on commit 728d003

Please sign in to comment.