diff --git a/src/Commands/Clone.cs b/src/Commands/Clone.cs index efec264b8..1e474399c 100644 --- a/src/Commands/Clone.cs +++ b/src/Commands/Clone.cs @@ -2,13 +2,16 @@ { public class Clone : Command { - public Clone(string ctx, string path, string url, string localName, string sshKey, string extraArgs) + public Clone(string ctx, string path, string url, string localName, string sshKey, int depth, string extraArgs) { Context = ctx; WorkingDirectory = path; SSHKey = sshKey; Args = "clone --progress --verbose "; + if(depth > 0) + Args += $"--depth {depth} --no-single-branch "; + if (!string.IsNullOrEmpty(extraArgs)) Args += $"{extraArgs} "; diff --git a/src/Commands/Fetch.cs b/src/Commands/Fetch.cs index 9ec27656a..3119aae2f 100644 --- a/src/Commands/Fetch.cs +++ b/src/Commands/Fetch.cs @@ -4,7 +4,7 @@ namespace SourceGit.Commands { public class Fetch : Command { - public Fetch(string repo, string remote, bool noTags, bool force) + public Fetch(string repo, string remote, bool noTags, bool force, int depth) { _remoteKey = $"remote.{remote}.sshkey"; @@ -20,16 +20,24 @@ public Fetch(string repo, string remote, bool noTags, bool force) if (force) Args += "--force "; + if(depth > 0) + Args += $"--depth {depth} "; + Args += remote; } - public Fetch(string repo, Models.Branch local, Models.Branch remote) + public Fetch(string repo, Models.Branch local, Models.Branch remote, int depth) { _remoteKey = $"remote.{remote.Remote}.sshkey"; WorkingDirectory = repo; Context = repo; - Args = $"fetch --progress --verbose {remote.Remote} {remote.Name}:{local.Name}"; + Args = "fetch --progress --verbose "; + + if(depth > 0) + Args += $"--depth {depth} "; + + Args += $"{remote.Remote} {remote.Name}:{local.Name}"; } public async Task RunAsync() diff --git a/src/Commands/Pull.cs b/src/Commands/Pull.cs index 93896c754..0b9f937be 100644 --- a/src/Commands/Pull.cs +++ b/src/Commands/Pull.cs @@ -4,7 +4,7 @@ namespace SourceGit.Commands { public class Pull : Command { - public Pull(string repo, string remote, string branch, bool useRebase) + public Pull(string repo, string remote, string branch, bool useRebase, int depth) { _remote = remote; @@ -15,6 +15,9 @@ public Pull(string repo, string remote, string branch, bool useRebase) if (useRebase) Args += "--rebase=true "; + if(depth > 0) + Args += $"--depth {depth} "; + Args += $"{remote} {branch}"; } diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index 0ca4eda27..2fe5b2579 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -236,6 +236,18 @@ public string LastCommitMessage set; } = string.Empty; + public bool UseCustomDepth + { + get; + set; + } = false; + + public int Depth + { + get; + set; + } = 1; + public Dictionary CollectHistoriesFilters() { var map = new Dictionary(); diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 87adcdda1..6c4dea12d 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -125,6 +125,7 @@ Übergeordneter Ordner: Submodule initialisieren und aktualisieren Repository URL: + Use Custom Depth SCHLIESSEN Editor Commit auschecken @@ -214,6 +215,7 @@ Minute(n) Standard Remote Bevorzugter Merge Modus + Use Custom Depth TICKETSYSTEM Beispiel für Azure DevOps Regel hinzufügen Beispiel für Gerrit Change-Id hinzufügen @@ -368,6 +370,7 @@ Ohne Tags fetchen Remote: Remote-Änderungen fetchen + Use Custom Depth Als unverändert betrachten Verwerfen... Verwerfe {0} Dateien... @@ -589,6 +592,7 @@ Benutzername Globaler Git Benutzername Git Version + Custom Depth By Default GPG SIGNIERUNG Commit-Signierung GPG Format @@ -612,6 +616,7 @@ Verwerfen Stashen & wieder anwenden Alle Submodule aktualisieren + Use Custom Depth Remote: Pull (Fetch & Merge) Rebase anstatt Merge verwenden diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index cf2d1ea91..d2daf7d2c 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -121,6 +121,7 @@ Parent Folder: Initialize & update submodules Repository URL: + Use Custom Depth CLOSE Editor Checkout Commit @@ -212,6 +213,7 @@ Minute(s) Default Remote Preferred Merge Mode + Use Custom Depth ISSUE TRACKER Add Azure DevOps Rule Add Gerrit Change-Id Commit Rule @@ -367,6 +369,7 @@ Fetch without tags Remote: Fetch Remote Changes + Use Custom Depth Assume unchanged Discard... Discard {0} files... @@ -579,6 +582,7 @@ GIT Enable Auto CRLF Default Clone Dir + Custom Depth By Default User Email Global git user email Enable --prune on fetch @@ -616,6 +620,7 @@ Remote: Pull (Fetch & Merge) Use rebase instead of merge + Use Custom Depth Push Make sure submodules have been pushed Force push diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index 292705a30..10254333f 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -125,6 +125,7 @@ Carpeta Padre: Inicializar y actualizar submódulos URL del Repositorio: + Use Custom Depth CERRAR Editor Checkout Commit @@ -216,6 +217,7 @@ Minuto(s) Remoto por Defecto Modo preferido de Merge + Use Custom Depth SEGUIMIENTO DE INCIDENCIAS Añadir Regla de Ejemplo para Azure DevOps Añadir Regla de "Gerrit Change-Id Commit" @@ -371,6 +373,7 @@ Fetch sin etiquetas Remoto: Fetch Cambios Remotos + Use Custom Depth Asumir como sin cambios Descartar... Descartar {0} archivos... @@ -593,6 +596,7 @@ Nombre del usuario Nombre global del usuario git Versión de Git + Custom Depth By Default FIRMA GPG Firma GPG en commit Formato GPG @@ -619,6 +623,7 @@ Remoto: Pull (Fetch & Merge) Usar rebase en lugar de merge + Use Custom Depth Push Asegurarse de que los submódulos se hayan hecho push Forzar push diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index 32ae0e9f9..df8504096 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -93,6 +93,7 @@ Dossier parent : Initialiser et mettre à jour les sous-modules URL du dépôt : + Use Custom Depth FERMER Éditeur Récupérer ce commit @@ -147,6 +148,7 @@ Fetch les dépôts distants automatiquement minute(s) Dépôt par défaut + Use Custom Depth SUIVI DES PROBLÈMES Ajouter une règle d'exemple Azure DevOps Ajouter une règle d'exemple Gitee @@ -263,6 +265,7 @@ Fetch sans les tags Remote : Récupérer les changements distants + Use Custom Depth Présumer inchangé Rejeter... Rejeter {0} fichiers... @@ -466,6 +469,7 @@ Nom d'utilisateur Nom d'utilisateur global Version de Git + Custom Depth By Default SIGNATURE GPG Signature GPG de commit Format GPG @@ -491,6 +495,7 @@ Dépôt distant : Pull (Fetch & Merge) Utiliser rebase au lieu de merge + Use Custom Depth Pousser Assurez-vous que les submodules ont été poussés Poussage forcé diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index 7d05b8c9f..82a60083b 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -119,6 +119,7 @@ Cartella Principale: Inizializza e aggiorna i sottomoduli URL del Repository: + Use Custom Depth CHIUDI Editor Checkout Commit @@ -206,6 +207,7 @@ Minuto/i Remoto Predefinito Modalità di Merge Preferita + Use Custom Depth TRACCIAMENTO ISSUE Aggiungi una regola di esempio per Azure DevOps Aggiungi regola per Gerrit Change-Id Commit @@ -357,6 +359,7 @@ Recupera senza tag Remoto: Recupera Modifiche Remote + Use Custom Depth Presumi invariato Scarta... Scarta {0} file... @@ -574,6 +577,7 @@ Nome Utente Nome utente Git globale Versione di Git + Custom Depth By Default FIRMA GPG Firma GPG per commit Formato GPG @@ -600,6 +604,7 @@ Remoto: Scarica (Recupera e Unisci) Riallineare anziché unire + Use Custom Depth Invia Assicurati che i sottomoduli siano stati inviati Forza l'invio diff --git a/src/Resources/Locales/ja_JP.axaml b/src/Resources/Locales/ja_JP.axaml index 4698a5508..76f97e412 100644 --- a/src/Resources/Locales/ja_JP.axaml +++ b/src/Resources/Locales/ja_JP.axaml @@ -92,6 +92,7 @@ 親フォルダ: サブモジュールを初期化して更新 リポジトリのURL: + Use Custom Depth 閉じる エディタ コミットをチェックアウト @@ -146,6 +147,7 @@ 自動的にリモートからフェッチ 間隔: 分(s) リモートの初期値 + Use Custom Depth ISSUEトラッカー サンプルのAzure DevOpsルールを追加 サンプルのGitee Issueルールを追加 @@ -262,6 +264,7 @@ タグなしでフェッチ リモート: リモートの変更をフェッチ + Use Custom Depth 変更されていないとみなされる 破棄... {0}個のファイルを破棄... @@ -465,6 +468,7 @@ ユーザー名 グローバルのgitユーザー名 Gitバージョン + Custom Depth By Default GPG 署名 コミットにGPG署名を行う GPGフォーマット @@ -490,6 +494,7 @@ リモート: プル (フェッチ & マージ) マージの代わりにリベースを使用 + Use Custom Depth プッシュ サブモジュールがプッシュされていることを確認 強制的にプッシュ diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index bc1f92ebe..6659383bc 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -84,6 +84,7 @@ Nome do repositório. Opcional. Pasta Pai: URL do Repositório: + Use Custom Depth FECHAR Editor Checar Commit @@ -132,6 +133,7 @@ Buscar remotos automaticamente Minuto(s) Remoto padrão + Use Custom Depth RASTREADOR DE PROBLEMAS Adicionar Regra de Exemplo do Azure DevOps Adicionar Regra de Exemplo do GitHub @@ -239,6 +241,7 @@ Buscar sem tags Remoto: Buscar Alterações Remotas + Use Custom Depth Assumir não alterado Descartar... Descartar {0} arquivos... @@ -425,6 +428,7 @@ Nome do Usuário Nome global do usuário git Versão do Git + Custom Depth By Default ASSINATURA GPG Assinatura GPG de commit Formato GPG @@ -450,6 +454,7 @@ Remoto: Puxar (Buscar & Mesclar) Usar rebase em vez de merge + Use Custom Depth Empurrar Certifica de que submodules foram enviadas Forçar push diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index deb6aef03..8958bd063 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -125,6 +125,7 @@ Родительский каталог: Создать и обновить подмодули Адрес репозитория: + Use Custom Depth ЗАКРЫТЬ Редактор Переключиться на эту ревизию @@ -216,6 +217,7 @@ Минут(а/ы) Внешний репозиторий по умолчанию Предпочтительный режим слияния + Use Custom Depth ОТСЛЕЖИВАНИЕ ПРОБЛЕМ Добавить пример правила Azure DevOps Добавить правило Gerrit ревизии идентификатора изменения @@ -371,6 +373,7 @@ Извлечь без меток Внешний репозиторий: Извлечь внешние изменения + Use Custom Depth Не отслеживать Отклонить... Отклонить {0} файлов... @@ -593,6 +596,7 @@ Имя пользователя Общее имя пользователя git Версия Git + Custom Depth By Default GPG ПОДПИСЬ GPG подпись ревизии Формат GPG @@ -619,6 +623,7 @@ Внешний репозиторий: Загрузить (Получить и слить) Использовать перемещение вместо слияния + Use Custom Depth Выложить Убедитесь, что подмодули были вставлены Принудительно выложить diff --git a/src/Resources/Locales/ta_IN.axaml b/src/Resources/Locales/ta_IN.axaml index a29ccef34..1d6cc6544 100644 --- a/src/Resources/Locales/ta_IN.axaml +++ b/src/Resources/Locales/ta_IN.axaml @@ -92,6 +92,7 @@ பெற்றோர் கோப்புறை: துவக்கு & துணை தொகுதிகளைப் புதுப்பி களஞ்சிய முகவரி: + Use Custom Depth மூடு திருத்தி உறுதிமொழி சரிபார் @@ -146,6 +147,7 @@ தொலைகளை தானாக எடு நிமையங்கள் இயல்புநிலை தொலை + Use Custom Depth சிக்கல் கண்காணி மாதிரி அசூர் வளர்பணிகள் விதியைச் சேர் மாதிரி அறிவிலிஈ சிக்கலுக்கான விதியைச் சேர் @@ -262,6 +264,7 @@ குறிச்சொற்கள் இல்லாமல் பெறு தொலை: தொலை மாற்றங்களைப் பெறு + Use Custom Depth மாறாமல் என கருது நிராகரி... {0} கோப்புகளை நிராகரி... @@ -465,6 +468,7 @@ பயனர் பெயர் உலகளாவிய அறிவிலி பயனர் பெயர் அறிவிலி பதிப்பு + Custom Depth By Default சிபிசி கையொப்பமிடுதல் சிபிசி கையொப்பமிடுதல் உறுதிமொழி சிபிசி வடிவம் @@ -490,6 +494,7 @@ தொலை: இழு (எடுத்து ஒன்றிணை) ஒன்றிணை என்பதற்குப் பதிலாக மறுதளத்தைப் பயன்படுத்து + Use Custom Depth தள்ளு துணைத் தொகுதிகள் தள்ளப்பட்டது என்பதை உறுதிசெய் கட்டாயமாக தள்ளு diff --git a/src/Resources/Locales/uk_UA.axaml b/src/Resources/Locales/uk_UA.axaml index 82e2a0c6f..8f23eb450 100644 --- a/src/Resources/Locales/uk_UA.axaml +++ b/src/Resources/Locales/uk_UA.axaml @@ -93,6 +93,7 @@ Батьківська тека: Ініціалізувати та оновити підмодулі URL сховища: + Use Custom Depth ЗАКРИТИ Редактор Перейти на коміт @@ -148,6 +149,7 @@ хвилин(и) Віддалене сховище за замовчуванням Бажаний режим злиття + Use Custom Depth ТРЕКЕР ЗАВДАНЬ Додати приклад правила для Azure DevOps Додати приклад правила для Gitee Issue @@ -267,6 +269,7 @@ Витягти без тегів Віддалений: Витягти зміни з віддалених репозиторіїв + Use Custom Depth Вважати незмінними Скасувати... Скасувати {0} файлів... @@ -470,6 +473,7 @@ Ім'я користувача Глобальне ім'я користувача git Версія Git + Custom Depth By Default ПІДПИС GPG Підпис GPG для комітів Формат GPG @@ -495,6 +499,7 @@ Віддалене сховище: Pull (Fetch & Merge) Використовувати rebase замість merge + Use Custom Depth Push (Надіслати) Переконатися, що підмодулі надіслано Примусовий push diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index b96f736ca..d5d38497d 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -125,6 +125,7 @@ 父级目录 : 初始化并更新子模块 远程仓库 : + Use Custom Depth 关闭 提交信息编辑器 检出此提交 @@ -216,6 +217,7 @@ 分钟 默认远程 默认合并方式 + Use Custom Depth ISSUE追踪 新增匹配Azure DevOps规则 新增匹配Gerrit Change-Id规则 @@ -371,6 +373,7 @@ 不拉取远程标签 远程仓库 : 拉取远程仓库内容 + Use Custom Depth 不跟踪此文件的更改 放弃更改... 放弃 {0} 个文件的更改... @@ -594,6 +597,7 @@ 用户名 默认GIT用户名 Git 版本 + Custom Depth By Default GPG签名 启用提交签名 签名格式 @@ -620,6 +624,7 @@ 远程 : 拉回(拉取并合并) 使用变基方式合并分支 + Use Custom Depth 推送(push) 确保子模块变更已推送 启用强制推送 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 605be607c..432bab13e 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -125,6 +125,7 @@ 上層目錄: 初始化並更新子模組 遠端存放庫: + Use Custom Depth 關閉 提交訊息編輯器 簽出 (checkout) 此提交 @@ -216,6 +217,7 @@ 分鐘 預設遠端存放庫 預設合併模式 + Use Custom Depth Issue 追蹤 新增符合 Azure DevOps 規則 新增符合 Gerrit Change-Id 規則 @@ -371,6 +373,7 @@ 不提取遠端標籤 遠端存放庫: 提取遠端存放庫內容 + Use Custom Depth 不追蹤此檔案的變更 捨棄變更... 捨棄已選的 {0} 個檔案變更... @@ -594,6 +597,7 @@ 使用者名稱 預設 Git 使用者名稱 Git 版本 + Custom Depth By Default GPG 簽章 啟用提交簽章 GPG 簽章格式 @@ -620,6 +624,7 @@ 遠端: 拉取 (提取並合併) 使用重定基底 (rebase) 合併分支 + Use Custom Depth 推送 (push) 確保已推送子模組 啟用強制推送 diff --git a/src/ViewModels/AddRemote.cs b/src/ViewModels/AddRemote.cs index fb5f0264b..cbbd77eed 100644 --- a/src/ViewModels/AddRemote.cs +++ b/src/ViewModels/AddRemote.cs @@ -105,7 +105,7 @@ public override async Task Sure() .Use(log) .SetAsync($"remote.{_name}.sshkey", _useSSH ? SSHKey : null); - await new Commands.Fetch(_repo.FullPath, _name, false, false) + await new Commands.Fetch(_repo.FullPath, _name, false, false, _repo.Settings.UseCustomDepth ? _repo.Settings.Depth : Preferences.Instance.RepositoryDepth) .Use(log) .RunAsync(); } diff --git a/src/ViewModels/Clone.cs b/src/ViewModels/Clone.cs index cfcf51bf2..56f2ea754 100644 --- a/src/ViewModels/Clone.cs +++ b/src/ViewModels/Clone.cs @@ -52,6 +52,18 @@ public string ExtraArgs set => SetProperty(ref _extraArgs, value); } + public bool UseCustomDepth + { + get => _useCustomDepth; + set => SetProperty(ref _useCustomDepth, value); + } + + public int Depth + { + get => _depth; + set => SetProperty(ref _depth, value); + } + public bool InitAndUpdateSubmodules { get; @@ -100,10 +112,11 @@ public override async Task Sure() { ProgressDescription = "Clone ..."; + var depth = _useCustomDepth ? _depth : Preferences.Instance.CustomDepthByDefault ? Preferences.Instance.RepositoryDepth : -1; var log = new CommandLog("Clone"); Use(log); - var succ = await new Commands.Clone(_pageId, _parentFolder, _remote, _local, _useSSH ? _sshKey : "", _extraArgs) + var succ = await new Commands.Clone(_pageId, _parentFolder, _remote, _local, _useSSH ? _sshKey : "", depth, _extraArgs) .Use(log) .ExecAsync(); if (!succ) @@ -173,5 +186,7 @@ public override async Task Sure() private string _parentFolder = string.Empty; private string _local = string.Empty; private string _extraArgs = string.Empty; + private bool _useCustomDepth = false; + private int _depth = 1; } } diff --git a/src/ViewModels/Fetch.cs b/src/ViewModels/Fetch.cs index de010da82..2d3ac205c 100644 --- a/src/ViewModels/Fetch.cs +++ b/src/ViewModels/Fetch.cs @@ -43,6 +43,18 @@ public bool Force set => _repo.Settings.EnableForceOnFetch = value; } + public bool UseCustomDepth + { + get => _useCustomDepth; + set => SetProperty(ref _useCustomDepth, value); + } + + public int Depth + { + get => _depth; + set => SetProperty(ref _depth, value); + } + public Fetch(Repository repo, Models.Remote preferredRemote = null) { _repo = repo; @@ -70,19 +82,20 @@ public override async Task Sure() var notags = _repo.Settings.FetchWithoutTags; var force = _repo.Settings.EnableForceOnFetch; + var depth = _useCustomDepth ? _depth : _repo.Depth; var log = _repo.CreateLog("Fetch"); Use(log); if (FetchAllRemotes) { foreach (var remote in _repo.Remotes) - await new Commands.Fetch(_repo.FullPath, remote.Name, notags, force) + await new Commands.Fetch(_repo.FullPath, remote.Name, notags, force, depth) .Use(log) .RunAsync(); } else { - await new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, force) + await new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, force, depth) .Use(log) .RunAsync(); } @@ -102,5 +115,7 @@ public override async Task Sure() private readonly Repository _repo = null; private bool _fetchAllRemotes = false; + private bool _useCustomDepth = false; + private int _depth = 1; } } diff --git a/src/ViewModels/FetchInto.cs b/src/ViewModels/FetchInto.cs index 6e435a305..cc1ef5f17 100644 --- a/src/ViewModels/FetchInto.cs +++ b/src/ViewModels/FetchInto.cs @@ -29,7 +29,7 @@ public override async Task Sure() var log = _repo.CreateLog($"Fetch Into '{Local.FriendlyName}'"); Use(log); - await new Commands.Fetch(_repo.FullPath, Local, Upstream) + await new Commands.Fetch(_repo.FullPath, Local, Upstream, _repo.Depth) .Use(log) .RunAsync(); diff --git a/src/ViewModels/Preferences.cs b/src/ViewModels/Preferences.cs index e416952c1..698ba0c89 100644 --- a/src/ViewModels/Preferences.cs +++ b/src/ViewModels/Preferences.cs @@ -137,6 +137,18 @@ public int MaxHistoryCommits set => SetProperty(ref _maxHistoryCommits, value); } + public bool CustomDepthByDefault + { + get => _customDepthByDefault; + set => SetProperty(ref _customDepthByDefault, value); + } + + public int RepositoryDepth + { + get => _repositoryDepth; + set => SetProperty(ref _repositoryDepth, value); + } + public int SubjectGuideLength { get => _subjectGuideLength; @@ -728,6 +740,8 @@ private bool RemoveInvalidRepositoriesRecursive(List collection) private LayoutInfo _layout = new(); private int _maxHistoryCommits = 20000; + private bool _customDepthByDefault = false; + private int _repositoryDepth = 1; private int _subjectGuideLength = 50; private bool _useFixedTabWidth = true; private bool _useAutoHideScrollBars = true; diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index f5776561e..2dacdc49e 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -61,6 +61,18 @@ public bool RecurseSubmodules set => _repo.Settings.UpdateSubmodulesOnCheckoutBranch = value; } + public bool UseCustomDepth + { + get => _useCustomDepth; + set => SetProperty(ref _useCustomDepth, value); + } + + public int Depth + { + get => _depth; + set => SetProperty(ref _depth, value); + } + public Pull(Repository repo, Models.Branch specifiedRemoteBranch) { _repo = repo; @@ -115,6 +127,7 @@ public override async Task Sure() { using var lockWatcher = _repo.LockWatcher(); + var depth = _useCustomDepth ? _depth : _repo.Depth; var log = _repo.CreateLog("Pull"); Use(log); @@ -144,7 +157,8 @@ public override async Task Sure() _repo.FullPath, _selectedRemote.Name, !string.IsNullOrEmpty(Current.Upstream) && Current.Upstream.Equals(_selectedBranch.FullName) ? string.Empty : _selectedBranch.Name, - UseRebase).Use(log).RunAsync(); + UseRebase, + depth).Use(log).RunAsync(); if (rs) { if (updateSubmodules) @@ -213,5 +227,7 @@ private void PostRemoteSelected() private Models.Remote _selectedRemote = null; private List _remoteBranches = null; private Models.Branch _selectedBranch = null; + private bool _useCustomDepth = false; + private int _depth = 1; } } diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index a01415087..f56935bb9 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -35,6 +35,11 @@ public Models.RepositorySettings Settings get => _settings; } + public int Depth + { + get => Settings.UseCustomDepth ? Settings.Depth : Preferences.Instance.CustomDepthByDefault ? Preferences.Instance.RepositoryDepth : -1; + } + public Models.GitFlow GitFlow { get; @@ -2010,7 +2015,7 @@ private void FetchInBackground(object sender) if (_settings.FetchAllRemotes) { foreach (var remote in remotes) - await new Commands.Fetch(FullPath, remote, false, false) { RaiseError = false }.RunAsync(); + await new Commands.Fetch(FullPath, remote, false, false, Depth) { RaiseError = false }.RunAsync(); } else if (remotes.Count > 0) { @@ -2018,7 +2023,7 @@ private void FetchInBackground(object sender) remotes.Find(x => x.Equals(_settings.DefaultRemote, StringComparison.Ordinal)) : remotes[0]; - await new Commands.Fetch(FullPath, remote, false, false) { RaiseError = false }.RunAsync(); + await new Commands.Fetch(FullPath, remote, false, false, Depth) { RaiseError = false }.RunAsync(); } _lastFetchTime = DateTime.Now; diff --git a/src/ViewModels/RepositoryConfigure.cs b/src/ViewModels/RepositoryConfigure.cs index 0074a19f6..7cd9f4cda 100644 --- a/src/ViewModels/RepositoryConfigure.cs +++ b/src/ViewModels/RepositoryConfigure.cs @@ -102,6 +102,32 @@ public int? AutoFetchInterval } } + public bool UseCustomDepth + { + get => _repo.Settings.UseCustomDepth; + set + { + if (_repo.Settings.UseCustomDepth != value) + { + _repo.Settings.UseCustomDepth = value; + OnPropertyChanged(); + } + } + } + + public int Depth + { + get => _repo.Settings.Depth; + set + { + if (_repo.Settings.Depth != value) + { + _repo.Settings.Depth = value; + OnPropertyChanged(); + } + } + } + public AvaloniaList CommitTemplates { get => _repo.Settings.CommitTemplates; diff --git a/src/Views/Clone.axaml b/src/Views/Clone.axaml index 8c7c9fafc..af9c910fd 100644 --- a/src/Views/Clone.axaml +++ b/src/Views/Clone.axaml @@ -10,7 +10,7 @@ - + + + + + + + diff --git a/src/Views/Fetch.axaml b/src/Views/Fetch.axaml index c38fdb7e4..4044bb5a1 100644 --- a/src/Views/Fetch.axaml +++ b/src/Views/Fetch.axaml @@ -11,7 +11,7 @@ - + + + + + + + diff --git a/src/Views/Preferences.axaml b/src/Views/Preferences.axaml index f91034402..368797980 100644 --- a/src/Views/Preferences.axaml +++ b/src/Views/Preferences.axaml @@ -304,7 +304,7 @@ - + - + + + + + + + + + + + + + diff --git a/src/Views/RepositoryConfigure.axaml b/src/Views/RepositoryConfigure.axaml index ef682ec51..395781110 100644 --- a/src/Views/RepositoryConfigure.axaml +++ b/src/Views/RepositoryConfigure.axaml @@ -44,7 +44,7 @@ - + + + + + + +