diff --git a/src/Commands/QueryCommits.cs b/src/Commands/QueryCommits.cs index 9e1d9918..8ac9cbc5 100644 --- a/src/Commands/QueryCommits.cs +++ b/src/Commands/QueryCommits.cs @@ -41,7 +41,7 @@ namespace SourceGit.Commands search = argsBuilder.ToString(); } - else if (method == Models.CommitSearchMethod.ByFile) + else if (method == Models.CommitSearchMethod.ByPath) { search += $"-- \"{filter}\""; } diff --git a/src/Models/Commit.cs b/src/Models/Commit.cs index f0f4b39b..1bfed55b 100644 --- a/src/Models/Commit.cs +++ b/src/Models/Commit.cs @@ -12,7 +12,7 @@ namespace SourceGit.Models ByAuthor, ByCommitter, ByMessage, - ByFile, + ByPath, ByContent, } diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 9faed0f8..2ce384c0 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -648,8 +648,8 @@ Author Committer Content - File Message + Path SHA Current Branch Show Submodules as Tree diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 76fead12..8e2eeef0 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -652,8 +652,8 @@ 作者 提交者 变更内容 - 文件 提交信息 + 路径 提交指纹 仅在当前分支中查找 以树型结构展示 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 8b110b6a..732794fb 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -652,8 +652,8 @@ 作者 提交者 變更內容 - 檔案 提交訊息 + 路徑 提交編號 僅搜尋目前分支 以樹型結構展示 diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 3202c44c..74f298d6 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -2891,7 +2891,7 @@ namespace SourceGit.ViewModels private bool IsSearchingCommitsByFilePath() { - return _isSearching && _searchCommitFilterType == (int)Models.CommitSearchMethod.ByFile; + return _isSearching && _searchCommitFilterType == (int)Models.CommitSearchMethod.ByPath; } private void CalcWorktreeFilesForSearching() diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index fd32b436..1b56e213 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -594,7 +594,7 @@ namespace SourceGit.ViewModels if (_selectedUnstaged.Count == 1) { var change = _selectedUnstaged[0]; - var path = Path.GetFullPath(Path.Combine(_repo.FullPath, change.Path)); + var path = Native.OS.GetAbsPath(_repo.FullPath, change.Path); var explore = new MenuItem(); explore.Header = App.Text("RevealFile"); @@ -602,7 +602,11 @@ namespace SourceGit.ViewModels explore.IsEnabled = File.Exists(path) || Directory.Exists(path); explore.Click += (_, e) => { - Native.OS.OpenInFileManager(path, true); + if (string.IsNullOrEmpty(selectedSingleFolder)) + Native.OS.OpenInFileManager(path, true); + else + Native.OS.OpenInFileManager(Native.OS.GetAbsPath(_repo.FullPath, selectedSingleFolder), true); + e.Handled = true; }; menu.Items.Add(explore); @@ -982,7 +986,11 @@ namespace SourceGit.ViewModels copy.Icon = App.CreateMenuIcon("Icons.Copy"); copy.Click += (_, e) => { - App.CopyText(change.Path); + if (string.IsNullOrEmpty(selectedSingleFolder)) + App.CopyText(change.Path); + else + App.CopyText(selectedSingleFolder); + e.Handled = true; }; menu.Items.Add(copy); @@ -992,7 +1000,11 @@ namespace SourceGit.ViewModels copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy"); copyFullPath.Click += (_, e) => { - App.CopyText(Native.OS.GetAbsPath(_repo.FullPath, change.Path)); + if (string.IsNullOrEmpty(selectedSingleFolder)) + App.CopyText(path); + else + App.CopyText(Native.OS.GetAbsPath(_repo.FullPath, selectedSingleFolder)); + e.Handled = true; }; menu.Items.Add(copyFullPath); @@ -1154,6 +1166,27 @@ namespace SourceGit.ViewModels menu.Items.Add(new MenuItem() { Header = "-" }); menu.Items.Add(addToIgnore); + + var copy = new MenuItem(); + copy.Header = App.Text("CopyPath"); + copy.Icon = App.CreateMenuIcon("Icons.Copy"); + copy.Click += (_, e) => + { + App.CopyText(selectedSingleFolder); + e.Handled = true; + }; + + var copyFullPath = new MenuItem(); + copyFullPath.Header = App.Text("CopyPath"); + copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy"); + copyFullPath.Click += (_, e) => + { + App.CopyText(Native.OS.GetAbsPath(_repo.FullPath, selectedSingleFolder)); + e.Handled = true; + }; + menu.Items.Add(new MenuItem() { Header = "-" }); + menu.Items.Add(copy); + menu.Items.Add(copyFullPath); } } @@ -1205,7 +1238,7 @@ namespace SourceGit.ViewModels if (_selectedStaged.Count == 1) { var change = _selectedStaged[0]; - var path = Path.GetFullPath(Path.Combine(_repo.FullPath, change.Path)); + var path = Native.OS.GetAbsPath(_repo.FullPath, change.Path); var explore = new MenuItem(); explore.IsEnabled = File.Exists(path) || Directory.Exists(path); @@ -1213,7 +1246,11 @@ namespace SourceGit.ViewModels explore.Icon = App.CreateMenuIcon("Icons.Explore"); explore.Click += (_, e) => { - Native.OS.OpenInFileManager(path, true); + if (string.IsNullOrEmpty(selectedSingleFolder)) + Native.OS.OpenInFileManager(path, true); + else + Native.OS.OpenInFileManager(Native.OS.GetAbsPath(_repo.FullPath, selectedSingleFolder), true); + e.Handled = true; }; @@ -1391,7 +1428,11 @@ namespace SourceGit.ViewModels copyPath.Icon = App.CreateMenuIcon("Icons.Copy"); copyPath.Click += (_, e) => { - App.CopyText(change.Path); + if (string.IsNullOrEmpty(selectedSingleFolder)) + App.CopyText(change.Path); + else + App.CopyText(selectedSingleFolder); + e.Handled = true; }; @@ -1400,7 +1441,11 @@ namespace SourceGit.ViewModels copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy"); copyFullPath.Click += (_, e) => { - App.CopyText(Native.OS.GetAbsPath(_repo.FullPath, change.Path)); + if (string.IsNullOrEmpty(selectedSingleFolder)) + App.CopyText(path); + else + App.CopyText(Native.OS.GetAbsPath(_repo.FullPath, selectedSingleFolder)); + e.Handled = true; }; @@ -1480,6 +1525,31 @@ namespace SourceGit.ViewModels menu.Items.Add(new MenuItem() { Header = "-" }); menu.Items.Add(ai); } + + if (!string.IsNullOrEmpty(selectedSingleFolder)) + { + var copyPath = new MenuItem(); + copyPath.Header = App.Text("CopyPath"); + copyPath.Icon = App.CreateMenuIcon("Icons.Copy"); + copyPath.Click += (_, e) => + { + App.CopyText(selectedSingleFolder); + e.Handled = true; + }; + + var copyFullPath = new MenuItem(); + copyFullPath.Header = App.Text("CopyFullPath"); + copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy"); + copyFullPath.Click += (_, e) => + { + App.CopyText(Native.OS.GetAbsPath(_repo.FullPath, selectedSingleFolder)); + e.Handled = true; + }; + + menu.Items.Add(new MenuItem() { Header = "-" }); + menu.Items.Add(copyPath); + menu.Items.Add(copyFullPath); + } } return menu; diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index 6016cf47..f875bd7d 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -532,7 +532,7 @@ - +