refactor: change Copy File Name to Copy Full Path for selected file or change (#1132)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-03-28 18:01:15 +08:00
parent b26c8a64ad
commit 276d000bcf
No known key found for this signature in database
15 changed files with 54 additions and 51 deletions

View file

@ -162,6 +162,15 @@ namespace SourceGit.Native
_backend.OpenWithDefaultEditor(file);
}
public static string GetAbsPath(string root, string sub)
{
var fullpath = Path.Combine(root, sub);
if (OperatingSystem.IsWindows())
return fullpath.Replace('/', '\\');
return fullpath;
}
private static void UpdateGitVersion()
{
if (string.IsNullOrEmpty(_gitExecutable) || !File.Exists(_gitExecutable))

View file

@ -186,7 +186,6 @@
<x:String x:Key="Text.Copy" xml:space="preserve">Kopieren</x:String>
<x:String x:Key="Text.CopyAllText" xml:space="preserve">Kopiere gesamten Text</x:String>
<x:String x:Key="Text.CopyPath" xml:space="preserve">Pfad kopieren</x:String>
<x:String x:Key="Text.CopyFileName" xml:space="preserve">Dateinamen kopieren</x:String>
<x:String x:Key="Text.CreateBranch" xml:space="preserve">Branch erstellen...</x:String>
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">Basierend auf:</x:String>
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">Erstellten Branch auschecken</x:String>

View file

@ -186,7 +186,7 @@
<x:String x:Key="Text.Copy" xml:space="preserve">Copy</x:String>
<x:String x:Key="Text.CopyAllText" xml:space="preserve">Copy All Text</x:String>
<x:String x:Key="Text.CopyPath" xml:space="preserve">Copy Path</x:String>
<x:String x:Key="Text.CopyFileName" xml:space="preserve">Copy File Name</x:String>
<x:String x:Key="Text.CopyFullPath" xml:space="preserve">Copy Full Path</x:String>
<x:String x:Key="Text.CreateBranch" xml:space="preserve">Create Branch...</x:String>
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">Based On:</x:String>
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">Check out the created branch</x:String>

View file

@ -189,7 +189,6 @@
<x:String x:Key="Text.Copy" xml:space="preserve">Copiar</x:String>
<x:String x:Key="Text.CopyAllText" xml:space="preserve">Copiar Todo el Texto</x:String>
<x:String x:Key="Text.CopyPath" xml:space="preserve">Copiar Ruta</x:String>
<x:String x:Key="Text.CopyFileName" xml:space="preserve">Copiar Nombre del Archivo</x:String>
<x:String x:Key="Text.CreateBranch" xml:space="preserve">Crear Rama...</x:String>
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">Basado En:</x:String>
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">Checkout de la rama creada</x:String>

View file

@ -178,7 +178,6 @@
<x:String x:Key="Text.ConventionalCommit.Type" xml:space="preserve">Type de Changement :</x:String>
<x:String x:Key="Text.Copy" xml:space="preserve">Copier</x:String>
<x:String x:Key="Text.CopyAllText" xml:space="preserve">Copier tout le texte</x:String>
<x:String x:Key="Text.CopyFileName" xml:space="preserve">Copier le nom de fichier</x:String>
<x:String x:Key="Text.CopyPath" xml:space="preserve">Copier le chemin</x:String>
<x:String x:Key="Text.CreateBranch" xml:space="preserve">Créer une branche...</x:String>
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">Basé sur :</x:String>

View file

@ -189,7 +189,6 @@
<x:String x:Key="Text.Copy" xml:space="preserve">Copia</x:String>
<x:String x:Key="Text.CopyAllText" xml:space="preserve">Copia Tutto il Testo</x:String>
<x:String x:Key="Text.CopyPath" xml:space="preserve">Copia Percorso</x:String>
<x:String x:Key="Text.CopyFileName" xml:space="preserve">Copia Nome File</x:String>
<x:String x:Key="Text.CreateBranch" xml:space="preserve">Crea Branch...</x:String>
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">Basato Su:</x:String>
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">Checkout del Branch Creato</x:String>

View file

@ -196,7 +196,6 @@
<x:String x:Key="Text.Copy" xml:space="preserve">Copiar</x:String>
<x:String x:Key="Text.CopyAllText" xml:space="preserve">Copiar todo o texto</x:String>
<x:String x:Key="Text.CopyPath" xml:space="preserve">Copiar Caminho</x:String>
<x:String x:Key="Text.CopyFileName" xml:space="preserve">Copiar Nome do Arquivo</x:String>
<x:String x:Key="Text.CreateBranch" xml:space="preserve">Criar Branch...</x:String>
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">Baseado Em:</x:String>
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">Checar o branch criado</x:String>

View file

@ -190,7 +190,6 @@
<x:String x:Key="Text.Copy" xml:space="preserve">Копировать</x:String>
<x:String x:Key="Text.CopyAllText" xml:space="preserve">Копировать весь текст</x:String>
<x:String x:Key="Text.CopyPath" xml:space="preserve">Копировать путь</x:String>
<x:String x:Key="Text.CopyFileName" xml:space="preserve">Копировать имя файла</x:String>
<x:String x:Key="Text.CreateBranch" xml:space="preserve">Создать ветку...</x:String>
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">Основан на:</x:String>
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">Проверить созданную ветку</x:String>

View file

@ -189,7 +189,7 @@
<x:String x:Key="Text.Copy" xml:space="preserve">复制</x:String>
<x:String x:Key="Text.CopyAllText" xml:space="preserve">复制全部文本</x:String>
<x:String x:Key="Text.CopyPath" xml:space="preserve">复制路径</x:String>
<x:String x:Key="Text.CopyFileName" xml:space="preserve">复制文件名</x:String>
<x:String x:Key="Text.CopyFullPath" xml:space="preserve">复制完整路径</x:String>
<x:String x:Key="Text.CreateBranch" xml:space="preserve">新建分支 ...</x:String>
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">新分支基于 </x:String>
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">完成后切换到新分支</x:String>

View file

@ -189,7 +189,7 @@
<x:String x:Key="Text.Copy" xml:space="preserve">複製</x:String>
<x:String x:Key="Text.CopyAllText" xml:space="preserve">複製全部內容</x:String>
<x:String x:Key="Text.CopyPath" xml:space="preserve">複製路徑</x:String>
<x:String x:Key="Text.CopyFileName" xml:space="preserve">複製檔案名稱</x:String>
<x:String x:Key="Text.CopyFullPath" xml:space="preserve">複製完整路徑</x:String>
<x:String x:Key="Text.CreateBranch" xml:space="preserve">新增分支...</x:String>
<x:String x:Key="Text.CreateBranch.BasedOn" xml:space="preserve">新分支基於:</x:String>
<x:String x:Key="Text.CreateBranch.Checkout" xml:space="preserve">完成後切換到新分支</x:String>

View file

@ -163,15 +163,15 @@ namespace SourceGit.ViewModels
};
menu.Items.Add(copyPath);
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(change.Path));
App.CopyText(Native.OS.GetAbsPath(_repo, change.Path));
e.Handled = true;
};
menu.Items.Add(copyFileName);
menu.Items.Add(copyFullPath);
return menu;
}

View file

@ -425,17 +425,17 @@ namespace SourceGit.ViewModels
ev.Handled = true;
};
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(change.Path));
App.CopyText(Native.OS.GetAbsPath(_repo.FullPath, change.Path));
e.Handled = true;
};
menu.Items.Add(copyPath);
menu.Items.Add(copyFileName);
menu.Items.Add(copyFullPath);
return menu;
}
@ -562,17 +562,17 @@ namespace SourceGit.ViewModels
ev.Handled = true;
};
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(file.Path));
App.CopyText(Native.OS.GetAbsPath(_repo.FullPath, file.Path));
e.Handled = true;
};
menu.Items.Add(copyPath);
menu.Items.Add(copyFileName);
menu.Items.Add(copyFullPath);
return menu;
}

View file

@ -183,15 +183,15 @@ namespace SourceGit.ViewModels
};
menu.Items.Add(copyPath);
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(change.Path));
App.CopyText(Native.OS.GetAbsPath(_repo, change.Path));
e.Handled = true;
};
menu.Items.Add(copyFileName);
menu.Items.Add(copyFullPath);
return menu;
}

View file

@ -251,12 +251,12 @@ namespace SourceGit.ViewModels
ev.Handled = true;
};
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(change.Path));
App.CopyText(Native.OS.GetAbsPath(_repo.FullPath, change.Path));
e.Handled = true;
};
@ -267,7 +267,7 @@ namespace SourceGit.ViewModels
menu.Items.Add(resetToThisRevision);
menu.Items.Add(new MenuItem { Header = "-" });
menu.Items.Add(copyPath);
menu.Items.Add(copyFileName);
menu.Items.Add(copyFullPath);
return menu;
}

View file

@ -903,15 +903,15 @@ namespace SourceGit.ViewModels
};
menu.Items.Add(copy);
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(change.Path));
App.CopyText(Native.OS.GetAbsPath(_repo.FullPath, change.Path));
e.Handled = true;
};
menu.Items.Add(copyFileName);
menu.Items.Add(copyFullPath);
}
else
{
@ -1270,17 +1270,17 @@ namespace SourceGit.ViewModels
e.Handled = true;
};
var copyFileName = new MenuItem();
copyFileName.Header = App.Text("CopyFileName");
copyFileName.Icon = App.CreateMenuIcon("Icons.Copy");
copyFileName.Click += (_, e) =>
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Click += (_, e) =>
{
App.CopyText(Path.GetFileName(change.Path));
App.CopyText(Native.OS.GetAbsPath(_repo.FullPath, change.Path));
e.Handled = true;
};
menu.Items.Add(copyPath);
menu.Items.Add(copyFileName);
menu.Items.Add(copyFullPath);
}
else
{