mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-11 23:57:21 -08:00
feature: shows the git configured commit template in Template/Histories
popup (#846)
This commit is contained in:
parent
8d12227227
commit
82fc261743
1 changed files with 25 additions and 1 deletions
|
@ -1351,8 +1351,9 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
var menu = new ContextMenu();
|
||||
|
||||
var gitTemplate = new Commands.Config(_repo.FullPath).Get("commit.template");
|
||||
var templateCount = _repo.Settings.CommitTemplates.Count;
|
||||
if (templateCount == 0)
|
||||
if (templateCount == 0 && string.IsNullOrEmpty(gitTemplate))
|
||||
{
|
||||
menu.Items.Add(new MenuItem()
|
||||
{
|
||||
|
@ -1376,6 +1377,29 @@ namespace SourceGit.ViewModels
|
|||
};
|
||||
menu.Items.Add(item);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(gitTemplate))
|
||||
{
|
||||
var friendlyName = gitTemplate;
|
||||
if (!OperatingSystem.IsWindows())
|
||||
{
|
||||
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
var prefixLen = home.EndsWith('/') ? home.Length - 1 : home.Length;
|
||||
if (gitTemplate.StartsWith(home, StringComparison.Ordinal))
|
||||
friendlyName = "~" + gitTemplate.Substring(prefixLen);
|
||||
}
|
||||
|
||||
var gitTemplateItem = new MenuItem();
|
||||
gitTemplateItem.Header = new Views.NameHighlightedTextBlock("WorkingCopy.UseCommitTemplate", friendlyName);
|
||||
gitTemplateItem.Icon = App.CreateMenuIcon("Icons.Code");
|
||||
gitTemplateItem.Click += (_, e) =>
|
||||
{
|
||||
if (File.Exists(gitTemplate))
|
||||
CommitMessage = File.ReadAllText(gitTemplate);
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(gitTemplateItem);
|
||||
}
|
||||
}
|
||||
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
|
|
Loading…
Reference in a new issue