From d7fc5efec018c4801460cbe834bd6e4b743bf84d Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Mon, 20 Nov 2017 18:22:36 +0100 Subject: [PATCH] Updated LibGit2Sharp to version v0.24.0 API changed: -> repository.commit() now mandates 'author' and 'commiter' as two distinct parameters. I pass into both the same value by default. -> repository.Stage() passes to the static class 'Commands' taking the repo as a first parameters. -> repository.Pull() undergoes the same change -> repository.Checkout() also -> repository.Remove() also -> repository.Fetch() takes the biggest changes. -It now requires by default a refSpec. As we will usually fetch everything, I hardcoded on the code the classic "+refs/heads/*:refs/remotes/origin/*". -It also requires a logMessage, which I hardoced empty ("") -> repository.Branches[branch].Remote changes as well. Now this collection moves to the .Network class member of the repository, as repo.Network.Remotes[branch] Changes to be committed: modified: RetailCoder.VBE/Rubberduck.csproj modified: RetailCoder.VBE/packages.config modified: Rubberduck.SourceControl/GitProvider.cs modified: Rubberduck.SourceControl/Rubberduck.SourceControl.csproj new file: Rubberduck.SourceControl/_SourceControlClassDiagram.cd modified: Rubberduck.SourceControl/packages.config modified: RubberduckTests/RubberduckTests.csproj --- RetailCoder.VBE/Rubberduck.csproj | 9 +- RetailCoder.VBE/packages.config | 2 + Rubberduck.SourceControl/GitProvider.cs | 47 ++-- .../Rubberduck.SourceControl.csproj | 7 +- .../_SourceControlClassDiagram.cd | 237 ++++++++++++++++++ Rubberduck.SourceControl/packages.config | 2 +- RubberduckTests/RubberduckTests.csproj | 5 +- 7 files changed, 286 insertions(+), 23 deletions(-) create mode 100644 Rubberduck.SourceControl/_SourceControlClassDiagram.cd diff --git a/RetailCoder.VBE/Rubberduck.csproj b/RetailCoder.VBE/Rubberduck.csproj index 61aed19bf4..94b2817820 100644 --- a/RetailCoder.VBE/Rubberduck.csproj +++ b/RetailCoder.VBE/Rubberduck.csproj @@ -1,5 +1,6 @@  + @@ -12,7 +13,8 @@ Rubberduck v4.5 512 - 480c0557 + + ..\ true @@ -256,9 +258,9 @@ ..\libs\Infralution.Localization.Wpf.dll - + False - ..\packages\LibGit2Sharp.0.22.0-pre20150516171636\lib\net40\LibGit2Sharp.dll + ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll ..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll @@ -1485,6 +1487,7 @@ + diff --git a/RetailCoder.VBE/packages.config b/RetailCoder.VBE/packages.config index f6eb6900ea..85b2e69caf 100644 --- a/RetailCoder.VBE/packages.config +++ b/RetailCoder.VBE/packages.config @@ -7,6 +7,8 @@ + + diff --git a/Rubberduck.SourceControl/GitProvider.cs b/Rubberduck.SourceControl/GitProvider.cs index 0c3bda185e..5d1f01f89f 100644 --- a/Rubberduck.SourceControl/GitProvider.cs +++ b/Rubberduck.SourceControl/GitProvider.cs @@ -185,7 +185,8 @@ public override IRepository InitVBAProject(string directory) var status = repo.RetrieveStatus(new StatusOptions {DetectRenamesInWorkDir = true}); foreach (var stat in status.Untracked) { - repo.Stage(stat.FilePath); + // repo.Stage(stat.FilePath); //deprecated from LibGit2Sharp v0.24 + LibGit2Sharp.Commands.Stage(repo, stat.FilePath); } try @@ -193,7 +194,7 @@ public override IRepository InitVBAProject(string directory) //The default behavior of LibGit2Sharp.Repo.Commit is to throw an exception if no signature is found, // but BuildSignature() does not throw if a signature is not found, it returns "unknown" instead. // so we pass a signature that won't throw along to the commit. - repo.Commit("Initial Commit", GetSignature(repo)); + repo.Commit("Initial Commit", GetSignature(repo), GetSignature(repo)); } catch(LibGit2SharpException ex) { @@ -246,7 +247,15 @@ public override void Fetch([Optional] string remoteName) if (remote != null) { - _repo.Network.Fetch(remote); + //_repo.Network.Fetch(remote); // deprecated on LibGit2Sharp from v0.24.0 + /* + * The new functionality requires a refSpec. + * As I suppose we're just tracking by default the whole remote, + * then I choose to hardcode the refSpec here: + */ + // NOTE: hardcoded string + IEnumerable refSpec = new List() {"+refs/heads/*:refs/remotes/origin/*"}; + LibGit2Sharp.Commands.Fetch(_repo, remoteName, refSpec, null,""); } RequeryUnsyncedCommits(); @@ -270,7 +279,8 @@ public override void Pull() }; var signature = GetSignature(); - _repo.Network.Pull(signature, options); + //_repo.Network.Pull(signature, options); // deprecated on LibGit2Sharp from v0.24.0 + LibGit2Sharp.Commands.Pull(_repo, signature, options); base.Pull(); @@ -289,7 +299,7 @@ public override void Commit(string message) //The default behavior of LibGit2Sharp.Repo.Commit is to throw an exception if no signature is found, // but BuildSignature() does not throw if a signature is not found, it returns "unknown" instead. // so we pass a signature that won't throw along to the commit. - _repo.Commit(message, GetSignature()); + _repo.Commit(message, GetSignature(), GetSignature()); } catch (LibGit2SharpException ex) { @@ -301,7 +311,8 @@ public override void Stage(string filePath) { try { - _repo.Stage(filePath); + // _repo.Stage(filePath); // deprecated on LibGit2Sharp from v0.24.0 + LibGit2Sharp.Commands.Stage(_repo, filePath); } catch (LibGit2SharpException ex) { @@ -313,7 +324,8 @@ public override void Stage(IEnumerable filePaths) { try { - _repo.Stage(filePaths); + //_repo.Stage(filePaths); // deprecated on LibGit2Sharp from v0.24.0 + LibGit2Sharp.Commands.Stage(_repo, filePaths); } catch (LibGit2SharpException ex) { @@ -348,7 +360,8 @@ public override void Checkout(string branch) { try { - _repo.Checkout(_repo.Branches[branch]); + //_repo.Checkout(_repo.Branches[branch]); // deprecated on LibGit2Sharp from v0.24.0 + LibGit2Sharp.Commands.Checkout(_repo, branch); base.Checkout(branch); RequeryUnsyncedCommits(); @@ -364,7 +377,8 @@ public override void CreateBranch(string branch) try { _repo.CreateBranch(branch); - _repo.Checkout(branch); + //_repo.Checkout(branch); // deprecated on LibGit2Sharp from v0.24.0 + LibGit2Sharp.Commands.Checkout(_repo,branch); RequeryUnsyncedCommits(); } @@ -379,7 +393,8 @@ public override void CreateBranch(string sourceBranch, string branch) try { _repo.CreateBranch(branch, _repo.Branches[sourceBranch].Commits.Last()); - _repo.Checkout(branch); + //_repo.Checkout(branch); // deprecated on LibGit2Sharp from v0.24.0 + LibGit2Sharp.Commands.Checkout(_repo, branch); RequeryUnsyncedCommits(); } @@ -417,7 +432,8 @@ public override void Unpublish(string branch) { try { - var remote = _repo.Branches[branch].Remote; + //var remote = _repo.Branches[branch].Remote; // deprecated on LibGit2Sharp from v0.24.0 + var remote = _repo.Network.Remotes[branch]; _repo.Branches.Update(_repo.Branches[branch], b => b.Remote = remote.Name, b => b.TrackedBranch = null, b => b.UpstreamBranch = null); @@ -463,7 +479,8 @@ public override void AddFile(string filePath) try { // https://github.com/libgit2/libgit2sharp/wiki/Git-add - _repo.Stage(filePath); + //_repo.Stage(filePath); // deprecated on LibGit2Sharp from v0.24.0 + LibGit2Sharp.Commands.Stage(_repo, filePath); } catch (LibGit2SharpException ex) { @@ -481,7 +498,8 @@ public override void RemoveFile(string filePath, bool removeFromWorkingDirectory try { NotifyExternalFileChanges = false; - _repo.Remove(filePath, removeFromWorkingDirectory); + //_repo.Remove(filePath, removeFromWorkingDirectory); // deprecated on LibGit2Sharp from v0.24.0 + LibGit2Sharp.Commands.Remove(_repo, filePath, removeFromWorkingDirectory); NotifyExternalFileChanges = true; } catch (LibGit2SharpException ex) @@ -554,7 +572,8 @@ public override void DeleteBranch(string branchName) }; } - _repo.Network.Push(branch.Remote, ":" + _repo.Branches[branchName].UpstreamBranchCanonicalName, options); + //_repo.Network.Push(branch.Remote, ":" + _repo.Branches[branchName].UpstreamBranchCanonicalName, options); // deprecated on LibGit2Sharp from v0.24.0 + _repo.Network.Push(_repo.Network.Remotes[branchName], ":" + _repo.Branches[branchName].UpstreamBranchCanonicalName, options); } // remote local repo diff --git a/Rubberduck.SourceControl/Rubberduck.SourceControl.csproj b/Rubberduck.SourceControl/Rubberduck.SourceControl.csproj index 7f6b98014e..1cc499c4c5 100644 --- a/Rubberduck.SourceControl/Rubberduck.SourceControl.csproj +++ b/Rubberduck.SourceControl/Rubberduck.SourceControl.csproj @@ -38,9 +38,9 @@ 7.1 - - ..\packages\LibGit2Sharp.0.22.0-pre20150516171636\lib\net40\LibGit2Sharp.dll - True + + False + ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll False @@ -82,6 +82,7 @@ + diff --git a/Rubberduck.SourceControl/_SourceControlClassDiagram.cd b/Rubberduck.SourceControl/_SourceControlClassDiagram.cd new file mode 100644 index 0000000000..b0a2420a8d --- /dev/null +++ b/Rubberduck.SourceControl/_SourceControlClassDiagram.cd @@ -0,0 +1,237 @@ + + + + + + IAAAAAAAAAAAAAgAAAAAAAQAAAAAACAAAAAIAAAAAAA= + Branch.cs + + + + + + + AAACAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAIAAAAAA= + Commit.cs + + + + + + + AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAACAAAAAAAAAAA= + Credentials.cs + + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + Credentials.cs + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + Credentials.cs + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAQA= + DefaultSettings.cs + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAIAAA= + FileStatusEntry.cs + + + + + + + IIBAgEIEECAABCYAAEEEQAAAAAQAWQAAAMgCAAIQiBA= + GitProvider.cs + + + + + + + AgACAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + Repository.cs + + + + + + + AAAAAIAAAAAAAAAAAAAAAAAAAAAAAEAAAAQAIIAAAAA= + SourceControlConfigProvider.cs + + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + SourceControlException.cs + + + + + + IoBAgFAEEABABCYCAEEECIAAAAQASQAAAIgCAIIQiBA= + SourceControlProviderBase.cs + + + + + + + AAAAAAQAAAAAAAAAgAAAAAQAIAAAAAAAAQAAAgAAAAA= + SourceControlSettings.cs + + + + + + + CAAAAAAAQAAAoAAgAkABEAIAEQAAIlQEABAgAEAAAIg= + + + + + + AIAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + Interop\Branches.cs + + + + + + + AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAACAAAAAAAAAAA= + Interop\Credentials.cs + + + + + + + + + + AAAAAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAAAAAAAAA= + Interop\FileStatusEntries.cs + + + + + + + AIAAAEAEAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABA= + Interop\GitProvider.cs + + + + + + + AAAAAABAAAAAAAAAgAAAAAQAAAAAAAAAAAAAAAAAAAA= + Interop\SourceControlClassFactory.cs + + + + + + + IAAAAAAAAAAAAAgAAAAAAAQAAAAAACAAAAAIAAAAAAA= + Branch.cs + + + + + + AAACAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAIAAAAAA= + Commit.cs + + + + + + AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAACAAAAAAAAAAA= + Credentials.cs + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAIAAA= + FileStatusEntry.cs + + + + + + AgACAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + IRepository.cs + + + + + + IoBAgFAEEAAABCYCAEEEAIAAAAQASQAAAIgCAIIQiBA= + ISourceControlProvider.cs + + + + + + AAAAAAQAAAAAAAAAAAAAAAQAIAAAAAAAAQAAAgAAAAA= + SourceControlSettings.cs + + + + + + AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAACAAAAAAAAAAA= + Interop\Credentials.cs + + + + + + IIBAAFAEEAAABAIAAAEAAAAAAAQAAQAAAAACAAIQiBA= + Interop\ISourceControlProvider.cs + + + + + + AAAAAABAAAAAAAAAgAAAAAQAAAAAAAAAAAAAAAAAAAA= + Interop\SourceControlClassFactory.cs + + + + + + AAAAAAAACAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA= + DefaultSettings.cs + + + + + + AAAAEgAAqAIAAEAAABAAAEABAACAAAAAAAgAAAAAEQA= + FileStatus.cs + + + + \ No newline at end of file diff --git a/Rubberduck.SourceControl/packages.config b/Rubberduck.SourceControl/packages.config index ce9f3bc615..0a039c16f2 100644 --- a/Rubberduck.SourceControl/packages.config +++ b/Rubberduck.SourceControl/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/RubberduckTests/RubberduckTests.csproj b/RubberduckTests/RubberduckTests.csproj index ac60a2ab4b..1c6312f726 100644 --- a/RubberduckTests/RubberduckTests.csproj +++ b/RubberduckTests/RubberduckTests.csproj @@ -49,8 +49,9 @@ ..\packages\Castle.Windsor.4.0.0\lib\net45\Castle.Windsor.dll - - ..\packages\LibGit2Sharp.0.22.0-pre20150516171636\lib\net40\LibGit2Sharp.dll + + False + ..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll