mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-06 19:44:58 +00:00
feature!: now SourceGit
requires git >= 2.25.1
Some checks are pending
Some checks are pending
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
7b05b011aa
commit
6e501b1ee4
21 changed files with 97 additions and 139 deletions
|
@ -54,7 +54,7 @@ You can find the current translation status in [TRANSLATION.md](https://github.c
|
|||
|
||||
## How to Use
|
||||
|
||||
**To use this tool, you need to install Git(>=2.23.0) first.**
|
||||
**To use this tool, you need to install Git(>=2.25.1) first.**
|
||||
|
||||
You can download the latest stable from [Releases](https://github.com/sourcegit-scm/sourcegit/releases/latest) or download workflow artifacts from [Github Actions](https://github.com/sourcegit-scm/sourcegit/actions) to try this app based on latest commits.
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace SourceGit.Commands
|
||||
namespace SourceGit.Commands
|
||||
{
|
||||
public class Add : Command
|
||||
{
|
||||
|
@ -12,20 +9,11 @@ namespace SourceGit.Commands
|
|||
Args = includeUntracked ? "add ." : "add -u .";
|
||||
}
|
||||
|
||||
public Add(string repo, List<string> changes)
|
||||
public Add(string repo, Models.Change change)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.Append("add --");
|
||||
foreach (var c in changes)
|
||||
{
|
||||
builder.Append(" \"");
|
||||
builder.Append(c);
|
||||
builder.Append("\"");
|
||||
}
|
||||
Args = builder.ToString();
|
||||
Args = $"add -- \"{change.Path}\"";
|
||||
}
|
||||
|
||||
public Add(string repo, string pathspecFromFile)
|
||||
|
|
|
@ -8,6 +8,12 @@ namespace SourceGit.Commands
|
|||
{
|
||||
public static class Discard
|
||||
{
|
||||
/// <summary>
|
||||
/// Discard all local changes (unstaged & staged)
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
/// <param name="includeIgnored"></param>
|
||||
/// <param name="log"></param>
|
||||
public static void All(string repo, bool includeIgnored, Models.ICommandLog log)
|
||||
{
|
||||
var changes = new QueryLocalChanges(repo).Result();
|
||||
|
@ -37,10 +43,17 @@ namespace SourceGit.Commands
|
|||
}
|
||||
|
||||
new Reset(repo, "HEAD", "--hard") { Log = log }.Exec();
|
||||
|
||||
if (includeIgnored)
|
||||
new Clean(repo) { Log = log }.Exec();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Discard selected changes (only unstaged).
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
/// <param name="changes"></param>
|
||||
/// <param name="log"></param>
|
||||
public static void Changes(string repo, List<Models.Change> changes, Models.ICommandLog log)
|
||||
{
|
||||
var restores = new List<string>();
|
||||
|
@ -71,20 +84,12 @@ namespace SourceGit.Commands
|
|||
});
|
||||
}
|
||||
|
||||
if (Native.OS.GitVersion >= Models.GitVersions.RESTORE_WITH_PATHSPECFILE)
|
||||
if (restores.Count > 0)
|
||||
{
|
||||
var tmpFile = Path.GetTempFileName();
|
||||
File.WriteAllLines(tmpFile, restores);
|
||||
new Restore(repo, tmpFile, "--worktree --recurse-submodules") { Log = log }.Exec();
|
||||
File.Delete(tmpFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < restores.Count; i += 32)
|
||||
{
|
||||
var count = Math.Min(32, restores.Count - i);
|
||||
new Restore(repo, restores.GetRange(i, count), "--worktree --recurse-submodules") { Log = log }.Exec();
|
||||
}
|
||||
var pathSpecFile = Path.GetTempFileName();
|
||||
File.WriteAllLines(pathSpecFile, restores);
|
||||
new Restore(repo, pathSpecFile, false) { Log = log }.Exec();
|
||||
File.Delete(pathSpecFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,58 +1,52 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
|
||||
namespace SourceGit.Commands
|
||||
{
|
||||
public class Restore : Command
|
||||
{
|
||||
/// <summary>
|
||||
/// Only used to discard all changes in the working directory and staged area.
|
||||
/// Only used for single staged change.
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
public Restore(string repo)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = "restore --source=HEAD --staged --worktree --recurse-submodules .";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Discard changes with git (< 2.25.0) that does not support the `--pathspec-from-file` option.
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
/// <param name="files"></param>
|
||||
/// <param name="extra"></param>
|
||||
public Restore(string repo, List<string> files, string extra)
|
||||
/// <param name="stagedChange"></param>
|
||||
public Restore(string repo, Models.Change stagedChange)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.Append("restore ");
|
||||
if (!string.IsNullOrEmpty(extra))
|
||||
builder.Append(extra).Append(" ");
|
||||
builder.Append("--");
|
||||
foreach (var f in files)
|
||||
builder.Append(' ').Append('"').Append(f).Append('"');
|
||||
builder.Append("restore --staged -- \"");
|
||||
builder.Append(stagedChange.Path);
|
||||
builder.Append('"');
|
||||
|
||||
if (stagedChange.Index == Models.ChangeState.Renamed)
|
||||
{
|
||||
builder.Append(" \"");
|
||||
builder.Append(stagedChange.OriginalPath);
|
||||
builder.Append('"');
|
||||
}
|
||||
|
||||
Args = builder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Discard changes with git (>= 2.25.0) that supports the `--pathspec-from-file` option.
|
||||
/// Restore changes given in a path-spec file.
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
/// <param name="pathspecFile"></param>
|
||||
/// <param name="extra"></param>
|
||||
public Restore(string repo, string pathspecFile, string extra)
|
||||
/// <param name="isStaged"></param>
|
||||
public Restore(string repo, string pathspecFile, bool isStaged)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.Append("restore ");
|
||||
if (!string.IsNullOrEmpty(extra))
|
||||
builder.Append(extra).Append(" ");
|
||||
builder.Append("--pathspec-from-file=\"").Append(pathspecFile).Append('"');
|
||||
builder.Append(isStaged ? "--staged " : "--worktree --recurse-submodules ");
|
||||
builder.Append("--pathspec-from-file=\"");
|
||||
builder.Append(pathspecFile);
|
||||
builder.Append('"');
|
||||
|
||||
Args = builder.ToString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,12 +28,13 @@ namespace SourceGit.Commands
|
|||
string tmp = Path.GetTempFileName();
|
||||
File.WriteAllText(tmp, message);
|
||||
cmd.Args += $"-F \"{tmp}\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Args += $"-m {name}";
|
||||
|
||||
var succ = cmd.Exec();
|
||||
File.Delete(tmp);
|
||||
return succ;
|
||||
}
|
||||
|
||||
cmd.Args += $"-m {name}";
|
||||
return cmd.Exec();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,26 +5,16 @@
|
|||
/// <summary>
|
||||
/// The minimal version of Git that required by this app.
|
||||
/// </summary>
|
||||
public static readonly System.Version MINIMAL = new System.Version(2, 23, 0);
|
||||
|
||||
/// <summary>
|
||||
/// The minimal version of Git that supports the `add` command with the `--pathspec-from-file` option.
|
||||
/// </summary>
|
||||
public static readonly System.Version ADD_WITH_PATHSPECFILE = new System.Version(2, 25, 0);
|
||||
|
||||
/// <summary>
|
||||
/// The minimal version of Git that supports the `restore` command with the `--pathspec-from-file` option.
|
||||
/// </summary>
|
||||
public static readonly System.Version RESTORE_WITH_PATHSPECFILE = new System.Version(2, 25, 0);
|
||||
public static readonly System.Version MINIMAL = new(2, 25, 1);
|
||||
|
||||
/// <summary>
|
||||
/// The minimal version of Git that supports the `stash push` command with the `--pathspec-from-file` option.
|
||||
/// </summary>
|
||||
public static readonly System.Version STASH_PUSH_WITH_PATHSPECFILE = new System.Version(2, 26, 0);
|
||||
public static readonly System.Version STASH_PUSH_WITH_PATHSPECFILE = new(2, 26, 0);
|
||||
|
||||
/// <summary>
|
||||
/// The minimal version of Git that supports the `stash push` command with the `--staged` option.
|
||||
/// </summary>
|
||||
public static readonly System.Version STASH_PUSH_ONLY_STAGED = new System.Version(2, 35, 0);
|
||||
public static readonly System.Version STASH_PUSH_ONLY_STAGED = new(2, 35, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -501,7 +501,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">Globale Git Benutzer Email</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">Aktivere --prune beim fetchen</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.IgnoreCRAtEOLInDiff" xml:space="preserve">Aktiviere --ignore-cr-at-eol beim Unterschied</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Diese App setzt Git (>= 2.23.0) voraus</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Diese App setzt Git (>= 2.25.1) voraus</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">Installationspfad</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">Aktiviere HTTP SSL Verifizierung</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">Benutzername</x:String>
|
||||
|
|
|
@ -511,7 +511,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">Global git user email</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">Enable --prune on fetch</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.IgnoreCRAtEOLInDiff" xml:space="preserve">Enable --ignore-cr-at-eol in diff</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Git (>= 2.23.0) is required by this app</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Git (>= 2.25.1) is required by this app</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">Install Path</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">Enable HTTP SSL Verify</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">User Name</x:String>
|
||||
|
|
|
@ -515,7 +515,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">Email global del usuario git</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">Habilitar --prune para fetch</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.IgnoreCRAtEOLInDiff" xml:space="preserve">Habilitar --ignore-cr-at-eol en diff</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Se requiere Git (>= 2.23.0) para esta aplicación</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Se requiere Git (>= 2.25.1) para esta aplicación</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">Ruta de instalación</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">Habilitar verificación HTTP SSL</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">Nombre de usuario</x:String>
|
||||
|
|
|
@ -483,7 +483,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email" xml:space="preserve">E-mail utilsateur</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">E-mail utilsateur global</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">Activer --prune pour fetch</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Cette application requière Git (>= 2.23.0)</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Cette application requière Git (>= 2.25.1)</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">Chemin d'installation</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">Activer la vérification HTTP SSL</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">Nom d'utilisateur</x:String>
|
||||
|
|
|
@ -504,7 +504,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">Email utente Git globale</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">Abilita --prune durante il fetch</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.IgnoreCRAtEOLInDiff" xml:space="preserve">Abilita --ignore-cr-at-eol nel diff</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Questa applicazione richiede Git (>= 2.23.0)</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Questa applicazione richiede Git (>= 2.25.1)</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">Percorso Installazione</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">Abilita la verifica HTTP SSL</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">Nome Utente</x:String>
|
||||
|
|
|
@ -482,7 +482,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email" xml:space="preserve">ユーザー Eメールアドレス</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">グローバルgitのEメールアドレス</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">フェッチ時に--pruneを有効化</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Git (>= 2.23.0) はこのアプリで必要です</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Git (>= 2.25.1) はこのアプリで必要です</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">インストール パス</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">HTTP SSL 検証を有効にする</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">ユーザー名</x:String>
|
||||
|
|
|
@ -440,7 +440,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email" xml:space="preserve">Email do Usuário</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">Email global do usuário git</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">Habilita --prune ao buscar</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Git (>= 2.23.0) é necessário para este aplicativo</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Git (>= 2.25.1) é necessário para este aplicativo</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">Caminho de Instalação</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">Nome do Usuário</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User.Placeholder" xml:space="preserve">Nome global do usuário git</x:String>
|
||||
|
|
|
@ -514,7 +514,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">Общая электроная почта пользователя git</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">Разрешить (--prune) при скачивании</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.IgnoreCRAtEOLInDiff" xml:space="preserve">Разрешить (--ignore-cr-at-eol) в сравнении</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Для работы программы требуется версия Git (>= 2.23.0)</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Для работы программы требуется версия Git (>= 2.25.1)</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">Путь установки</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">Разрешить верификацию HTTP SSL</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">Имя пользователя</x:String>
|
||||
|
|
|
@ -482,7 +482,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email" xml:space="preserve">பயனர் மின்னஞ்சல்</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">உலகளாவிய அறிவிலி பயனர் மின்னஞ்சல்</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">--prune எடுக்கும்போது இயக்கு</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">அறிவிலி (>= 2.23.0) இந்த பயன்பாட்டிற்கு தேவைப்படுகிறது</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">அறிவிலி (>= 2.25.1) இந்த பயன்பாட்டிற்கு தேவைப்படுகிறது</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">நிறுவல் பாதை</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">உஉபநெ பாகுஅ சரிபார்ப்பை இயக்கு</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">பயனர் பெயர்</x:String>
|
||||
|
|
|
@ -487,7 +487,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email" xml:space="preserve">Email користувача</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">Глобальний email користувача git</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">Увімкнути --prune при fetch</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Git (>= 2.23.0) є обов'язковим для цієї програми</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">Git (>= 2.25.1) є обов'язковим для цієї програми</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">Шлях встановлення</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">Увімкнути перевірку HTTP SSL</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">Ім'я користувача</x:String>
|
||||
|
|
|
@ -515,7 +515,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">默认GIT用户邮箱</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">拉取更新时启用修剪(--prune)</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.IgnoreCRAtEOLInDiff" xml:space="preserve">对比文件时,默认忽略换行符变更 (--ignore-cr-at-eol)</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">本软件要求GIT最低版本为2.23.0</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">本软件要求GIT最低版本为2.25.1</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">安装路径</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">启用HTTP SSL验证</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">用户名</x:String>
|
||||
|
|
|
@ -515,7 +515,7 @@
|
|||
<x:String x:Key="Text.Preferences.Git.Email.Placeholder" xml:space="preserve">預設 Git 使用者電子郵件</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.EnablePruneOnFetch" xml:space="preserve">拉取變更時進行清理 (--prune)</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.IgnoreCRAtEOLInDiff" xml:space="preserve">對比檔案時,預設忽略行尾的 CR 變更 (--ignore-cr-at-eol)</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">本軟體要求 Git 最低版本為 2.23.0</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Invalid" xml:space="preserve">本軟體要求 Git 最低版本為 2.25.1</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.Path" xml:space="preserve">安裝路徑</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.SSLVerify" xml:space="preserve">啟用 HTTP SSL 驗證</x:String>
|
||||
<x:String x:Key="Text.Preferences.Git.User" xml:space="preserve">使用者名稱</x:String>
|
||||
|
|
|
@ -117,10 +117,10 @@ namespace SourceGit.ViewModels
|
|||
foreach (var c in changes)
|
||||
paths.Add(c.Path);
|
||||
|
||||
var tmpFile = Path.GetTempFileName();
|
||||
File.WriteAllLines(tmpFile, paths);
|
||||
succ = new Commands.Stash(_repo.FullPath).Use(log).Push(Message, tmpFile, KeepIndex);
|
||||
File.Delete(tmpFile);
|
||||
var pathSpecFile = Path.GetTempFileName();
|
||||
File.WriteAllLines(pathSpecFile, paths);
|
||||
succ = new Commands.Stash(_repo.FullPath).Use(log).Push(Message, pathSpecFile, KeepIndex);
|
||||
File.Delete(pathSpecFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -412,7 +412,12 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
|
||||
if (needStage.Count > 0)
|
||||
await Task.Run(() => new Commands.Add(_repo.FullPath, needStage).Use(log).Exec());
|
||||
{
|
||||
var pathSpecFile = Path.GetTempFileName();
|
||||
await File.WriteAllLinesAsync(pathSpecFile, needStage);
|
||||
await Task.Run(() => new Commands.Add(_repo.FullPath, pathSpecFile).Use(log).Exec());
|
||||
File.Delete(pathSpecFile);
|
||||
}
|
||||
|
||||
log.Complete();
|
||||
_repo.MarkWorkingCopyDirtyManually();
|
||||
|
@ -456,7 +461,12 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
|
||||
if (needStage.Count > 0)
|
||||
await Task.Run(() => new Commands.Add(_repo.FullPath, needStage).Use(log).Exec());
|
||||
{
|
||||
var pathSpecFile = Path.GetTempFileName();
|
||||
await File.WriteAllLinesAsync(pathSpecFile, needStage);
|
||||
await Task.Run(() => new Commands.Add(_repo.FullPath, pathSpecFile).Use(log).Exec());
|
||||
File.Delete(pathSpecFile);
|
||||
}
|
||||
|
||||
log.Complete();
|
||||
_repo.MarkWorkingCopyDirtyManually();
|
||||
|
@ -467,7 +477,7 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
var toolType = Preferences.Instance.ExternalMergeToolType;
|
||||
var toolPath = Preferences.Instance.ExternalMergeToolPath;
|
||||
var file = change?.Path; // NOTE: With no <file> arg, mergetool runs on on every file with merge conflicts!
|
||||
var file = change?.Path; // NOTE: With no <file> arg, mergetool runs on every file with merge conflicts!
|
||||
await Task.Run(() => Commands.MergeTool.OpenForMerge(_repo.FullPath, toolType, toolPath, file));
|
||||
}
|
||||
|
||||
|
@ -770,7 +780,7 @@ namespace SourceGit.ViewModels
|
|||
byParentFolder.IsVisible = !isRooted;
|
||||
byParentFolder.Click += (_, e) =>
|
||||
{
|
||||
var dir = Path.GetDirectoryName(change.Path).Replace("\\", "/");
|
||||
var dir = Path.GetDirectoryName(change.Path)!.Replace("\\", "/");
|
||||
Commands.GitIgnore.Add(_repo.FullPath, dir + "/");
|
||||
e.Handled = true;
|
||||
};
|
||||
|
@ -792,7 +802,7 @@ namespace SourceGit.ViewModels
|
|||
byExtensionInSameFolder.IsVisible = !isRooted;
|
||||
byExtensionInSameFolder.Click += (_, e) =>
|
||||
{
|
||||
var dir = Path.GetDirectoryName(change.Path).Replace("\\", "/");
|
||||
var dir = Path.GetDirectoryName(change.Path)!.Replace("\\", "/");
|
||||
Commands.GitIgnore.Add(_repo.FullPath, $"{dir}/*{extension}");
|
||||
e.Handled = true;
|
||||
};
|
||||
|
@ -1619,31 +1629,19 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
await Task.Run(() => new Commands.Add(_repo.FullPath, _repo.IncludeUntracked).Use(log).Exec());
|
||||
}
|
||||
else if (Native.OS.GitVersion >= Models.GitVersions.ADD_WITH_PATHSPECFILE)
|
||||
{
|
||||
var paths = new List<string>();
|
||||
foreach (var c in changes)
|
||||
paths.Add(c.Path);
|
||||
|
||||
var tmpFile = Path.GetTempFileName();
|
||||
File.WriteAllLines(tmpFile, paths);
|
||||
await Task.Run(() => new Commands.Add(_repo.FullPath, tmpFile).Use(log).Exec());
|
||||
File.Delete(tmpFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
var paths = new List<string>();
|
||||
foreach (var c in changes)
|
||||
paths.Add(c.Path);
|
||||
|
||||
for (int i = 0; i < count; i += 32)
|
||||
{
|
||||
var step = paths.GetRange(i, Math.Min(32, count - i));
|
||||
await Task.Run(() => new Commands.Add(_repo.FullPath, step).Use(log).Exec());
|
||||
}
|
||||
var pathSpecFile = Path.GetTempFileName();
|
||||
await File.WriteAllLinesAsync(pathSpecFile, paths);
|
||||
await Task.Run(() => new Commands.Add(_repo.FullPath, pathSpecFile).Use(log).Exec());
|
||||
File.Delete(pathSpecFile);
|
||||
}
|
||||
log.Complete();
|
||||
|
||||
|
||||
_repo.MarkWorkingCopyDirtyManually();
|
||||
_repo.SetWatcherEnabled(true);
|
||||
IsStaging = false;
|
||||
|
@ -1667,7 +1665,7 @@ namespace SourceGit.ViewModels
|
|||
log.AppendLine("$ git update-index --index-info ");
|
||||
await Task.Run(() => new Commands.UnstageChangesForAmend(_repo.FullPath, changes).Exec());
|
||||
}
|
||||
else if (Native.OS.GitVersion >= Models.GitVersions.RESTORE_WITH_PATHSPECFILE)
|
||||
else
|
||||
{
|
||||
var paths = new List<string>();
|
||||
foreach (var c in changes)
|
||||
|
@ -1676,30 +1674,14 @@ namespace SourceGit.ViewModels
|
|||
if (c.Index == Models.ChangeState.Renamed)
|
||||
paths.Add(c.OriginalPath);
|
||||
}
|
||||
|
||||
var tmpFile = Path.GetTempFileName();
|
||||
File.WriteAllLines(tmpFile, paths);
|
||||
await Task.Run(() => new Commands.Restore(_repo.FullPath, tmpFile, "--staged").Use(log).Exec());
|
||||
File.Delete(tmpFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < count; i += 32)
|
||||
{
|
||||
var step = changes.GetRange(i, Math.Min(32, count - i));
|
||||
var files = new List<string>();
|
||||
foreach (var c in step)
|
||||
{
|
||||
files.Add(c.Path);
|
||||
if (c.Index == Models.ChangeState.Renamed)
|
||||
files.Add(c.OriginalPath);
|
||||
}
|
||||
|
||||
await Task.Run(() => new Commands.Restore(_repo.FullPath, files, "--staged").Use(log).Exec());
|
||||
}
|
||||
var pathSpecFile = Path.GetTempFileName();
|
||||
await File.WriteAllLinesAsync(pathSpecFile, paths);
|
||||
await Task.Run(() => new Commands.Restore(_repo.FullPath, pathSpecFile, true).Use(log).Exec());
|
||||
File.Delete(pathSpecFile);
|
||||
}
|
||||
log.Complete();
|
||||
|
||||
|
||||
_repo.MarkWorkingCopyDirtyManually();
|
||||
_repo.SetWatcherEnabled(true);
|
||||
IsUnstaging = false;
|
||||
|
|
|
@ -1868,7 +1868,7 @@ namespace SourceGit.Views
|
|||
|
||||
if (!selection.HasLeftChanges)
|
||||
{
|
||||
new Commands.Add(repo.FullPath, [change.Path]).Exec();
|
||||
new Commands.Add(repo.FullPath, change).Exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1928,10 +1928,8 @@ namespace SourceGit.Views
|
|||
{
|
||||
if (change.DataForAmend != null)
|
||||
new Commands.UnstageChangesForAmend(repo.FullPath, [change]).Exec();
|
||||
else if (change.Index == Models.ChangeState.Renamed)
|
||||
new Commands.Restore(repo.FullPath, [change.Path, change.OriginalPath], "--staged").Exec();
|
||||
else
|
||||
new Commands.Restore(repo.FullPath, [change.Path], "--staged").Exec();
|
||||
new Commands.Restore(repo.FullPath, change).Exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue