From ceff6ef1021b7ad59ddecc1e3f1f66a743d2b522 Mon Sep 17 00:00:00 2001 From: ZCShou <72115@163.com> Date: Fri, 24 Jul 2020 19:52:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(*):=20=E4=B8=BA=20Pull=E3=80=81Fetch?= =?UTF-8?q?=E3=80=81Push=20=E5=A2=9E=E5=8A=A0=20=20--recurse-submodules=20?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SourceGit/Git/Remote.cs | 2 +- SourceGit/Git/Repository.cs | 15 +++++++++------ SourceGit/UI/Fetch.xaml | 16 ++++++++++++---- SourceGit/UI/Fetch.xaml.cs | 15 ++++++++++++--- SourceGit/UI/Pull.xaml | 16 ++++++++++++---- SourceGit/UI/Pull.xaml.cs | 11 ++++++++++- SourceGit/UI/Push.xaml | 17 +++++++++++++---- SourceGit/UI/Push.xaml.cs | 18 +++++++++++++++--- 8 files changed, 84 insertions(+), 26 deletions(-) diff --git a/SourceGit/Git/Remote.cs b/SourceGit/Git/Remote.cs index ed32e810..1d1ade87 100644 --- a/SourceGit/Git/Remote.cs +++ b/SourceGit/Git/Remote.cs @@ -57,7 +57,7 @@ namespace SourceGit.Git { if (errs != null) { App.RaiseError(errs); } else { - repo.Fetch(new Remote() { Name = name }, true, null); + repo.Fetch(new Remote() { Name = name }, "--recurse-submodules=on-demand", true, null); } } diff --git a/SourceGit/Git/Repository.cs b/SourceGit/Git/Repository.cs index a96c93ae..b52f0b40 100644 --- a/SourceGit/Git/Repository.cs +++ b/SourceGit/Git/Repository.cs @@ -448,12 +448,13 @@ namespace SourceGit.Git { /// Fetch remote changes /// /// + /// submod /// /// - public void Fetch(Remote remote, bool prune, Action onProgress) { + public void Fetch(Remote remote, string submod, bool prune, Action onProgress) { isWatcherDisabled = true; - var args = "-c credential.helper=manager fetch --progress --verbose "; + var args = $"-c credential.helper=manager fetch --progress --verbose {submod} "; if (prune) args += "--prune "; @@ -475,14 +476,15 @@ namespace SourceGit.Git { /// /// remote /// branch + /// submod /// Progress message handler. /// Use rebase instead of merge. /// Auto stash local changes. /// Progress message handler. - public void Pull(string remote, string branch, Action onProgress, bool rebase = false, bool autostash = false) { + public void Pull(string remote, string branch, string submod, Action onProgress, bool rebase = false, bool autostash = false) { isWatcherDisabled = true; - var args = "-c credential.helper=manager pull --verbose --progress "; + var args = $"-c credential.helper=manager pull --verbose --progress {submod} "; var needPopStash = false; if (rebase) args += "--rebase "; @@ -518,14 +520,15 @@ namespace SourceGit.Git { /// Remote /// Local branch name /// Remote branch name + /// submod /// Progress message handler. /// Push tags /// Create track reference /// Force push - public void Push(string remote, string localBranch, string remoteBranch, Action onProgress, bool withTags = false, bool track = false, bool force = false) { + public void Push(string remote, string localBranch, string remoteBranch, string submod, Action onProgress, bool withTags = false, bool track = false, bool force = false) { isWatcherDisabled = true; - var args = "-c credential.helper=manager push --progress --verbose "; + var args = $"-c credential.helper=manager push --progress --verbose {submod} "; if (withTags) args += "--tags "; if (track) args += "-u "; diff --git a/SourceGit/UI/Fetch.xaml b/SourceGit/UI/Fetch.xaml index 550ed554..11e59594 100644 --- a/SourceGit/UI/Fetch.xaml +++ b/SourceGit/UI/Fetch.xaml @@ -6,7 +6,7 @@ xmlns:git="clr-namespace:SourceGit.Git" xmlns:converters="clr-namespace:SourceGit.Converters" mc:Ignorable="d" - d:DesignHeight="192" d:DesignWidth="500" Height="192" Width="500"> + d:DesignHeight="192" d:DesignWidth="500" Height="224" Width="500"> @@ -14,6 +14,7 @@ + @@ -41,17 +42,24 @@ - + + + + + + + - - + diff --git a/SourceGit/UI/Fetch.xaml.cs b/SourceGit/UI/Fetch.xaml.cs index 1068c518..8de01ebd 100644 --- a/SourceGit/UI/Fetch.xaml.cs +++ b/SourceGit/UI/Fetch.xaml.cs @@ -49,15 +49,24 @@ namespace SourceGit.UI { /// /// private async void Start(object sender, RoutedEventArgs e) { - bool prune = chkPrune.IsChecked == true; + bool prune = chkPrune.IsChecked == true; + + string subMod; + if (RbtnRrsSubModYes.IsChecked == true) { + subMod = "--recurse-submodules=yes"; + } else if (RbtnRrsSubModNo.IsChecked == true) { + subMod = "--recurse-submodules=no"; + } else { + subMod = "--recurse-submodules=on-demand"; + } PopupManager.Lock(); if (chkFetchAll.IsChecked == true) { - await Task.Run(() => repo.Fetch(null, prune, PopupManager.UpdateStatus)); + await Task.Run(() => repo.Fetch(null, subMod, prune, PopupManager.UpdateStatus)); } else { var remote = combRemotes.SelectedItem as Git.Remote; - await Task.Run(() => repo.Fetch(remote, prune, PopupManager.UpdateStatus)); + await Task.Run(() => repo.Fetch(remote, subMod, prune, PopupManager.UpdateStatus)); } PopupManager.Close(true); diff --git a/SourceGit/UI/Pull.xaml b/SourceGit/UI/Pull.xaml index 57c0e072..f24c67f0 100644 --- a/SourceGit/UI/Pull.xaml +++ b/SourceGit/UI/Pull.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" - d:DesignHeight="248" d:DesignWidth="500" Height="248" Width="500"> + d:DesignHeight="248" d:DesignWidth="500" Height="280" Width="500"> @@ -12,6 +12,7 @@ + @@ -60,19 +61,26 @@