diff --git a/src/Fixer.cs b/src/Fixer.cs index 1c38d4a..724e135 100644 --- a/src/Fixer.cs +++ b/src/Fixer.cs @@ -85,9 +85,6 @@ public void FixBranches() Log(sb.ToString()); } - bool cannotSetupTrackingInformation = false; - bool legacySvnBranchTrackingMessageDisplayed = false; - foreach (var b in svnBranches) { var branch = Regex.Replace(b, @"^svn\/", "").Trim(); @@ -116,50 +113,8 @@ public void FixBranches() continue; } - if (cannotSetupTrackingInformation) - { - CommandInfo ci = CommandInfoBuilder.BuildCheckoutSvnRemoteBranchCommandInfo(branch); - CommandRunner.Run(ci.Command, ci.Arguments); - } - else - { - CommandInfo trackCommandInfo = CommandInfoBuilder.BuildGitBranchTrackCommandInfo(branch); - - string trackCommandError = string.Empty; - string dummyOutput = string.Empty; - RunCommand(trackCommandInfo, out dummyOutput, out trackCommandError); - - // As of git 1.8.3.2, tracking information cannot be set up for remote SVN branches: - // http://git.661346.n2.nabble.com/git-svn-Use-prefix-by-default-td7594288.html#a7597159 - // - // Older versions of git can do it and it should be safe as long as remotes aren't pushed. - // Our --rebase option obviates the need for read-only tracked remotes, however. So, we'll - // deprecate the old option, informing those relying on the old behavior that they should - // use the newer --rebase option. - Log($"trackCommandError: {trackCommandError}"); - if (Regex.IsMatch(trackCommandError, @"(?m)Cannot setup tracking information")) - { - Log("Has tracking error."); - cannotSetupTrackingInformation = true; - - CommandInfo checkoutRemoteBranchCommandInfo = CommandInfoBuilder.BuildCheckoutSvnRemoteBranchCommandInfo(branch); - - RunCommand(checkoutRemoteBranchCommandInfo); - } - else - { - if (!legacySvnBranchTrackingMessageDisplayed) - { - ShowTrackingRemoteSvnBranchesDeprecatedWarning(); - } - - legacySvnBranchTrackingMessageDisplayed = true; - - CommandInfo checkoutLocalBranchCommandInfo = CommandInfoBuilder.BuildCheckoutLocalBranchCommandInfo(branch); - - RunCommand(checkoutLocalBranchCommandInfo); - } - } + // Now checkout the remote svn branch. + RunCommand(CommandInfoBuilder.BuildCheckoutSvnRemoteBranchCommandInfo(branch)); } Log("End fixing branches."); @@ -261,26 +216,5 @@ public void OptimizeRepos() { CommandRunner.Run("git", "gc"); } - - private void ShowTrackingRemoteSvnBranchesDeprecatedWarning() - { - StringBuilder message = new StringBuilder(); - for (int i = 0; i < 68; ++i) - { - message.Append("*"); - } - message.AppendLine(); - - message.AppendLine("svn2gitnet warning: Tracking remote SVN branches is deprecated."); - message.AppendLine("In a future release local branches will be created without tracking."); - message.AppendLine("If you must resync your branches, run: svn2gitnet --rebase"); - - for (int i = 0; i < 68; ++i) - { - message.Append("*"); - } - - ShowMessageIfPossible(message.ToString()); - } } } \ No newline at end of file diff --git a/tests/unittests/FixerTest.cs b/tests/unittests/FixerTest.cs index 75615dd..a76eb65 100644 --- a/tests/unittests/FixerTest.cs +++ b/tests/unittests/FixerTest.cs @@ -324,11 +324,6 @@ public void FixBranchesIsNotRebaseIsNotTrunkBranchTest() mock.Setup(f => f.Run("git", It.IsAny<string>())) .Returns(0); - string standardOutput = string.Empty; - string standardError = "Hello. Cannot setup tracking information!"; - mock.Setup(f => f.Run("git", "branch --track \"dev\" \"remotes/svn/dev\"", out standardOutput, out standardError)); - - MetaInfo metaInfo = new MetaInfo() { LocalBranches = new List<string>() @@ -353,87 +348,6 @@ public void FixBranchesIsNotRebaseIsNotTrunkBranchTest() // Assert mock.Verify(f => f.Run("git", "checkout -b \"dev\" \"remotes/svn/dev\""), Times.Once()); - mock.Verify(f => f.Run("git", "branch --track \"dev\" \"remotes/svn/dev\"", out standardOutput, out standardError), Times.Once()); - } - - [Fact] - public void FixBranchesIsNotRebaseIsNotTrunkBranchTrackingWarningTest() - { - // Prepare - var mock = new Mock<ICommandRunner>(); - mock.Setup(f => f.Run("git", It.IsAny<string>())) - .Returns(0); - - string standardOutput = string.Empty; - string standardError = "Hello. Cannot setup tracking information!"; - mock.Setup(f => f.Run("git", "branch --track \"dev\" \"remotes/svn/dev\"", out standardOutput, out standardError)); - - MetaInfo metaInfo = new MetaInfo() - { - LocalBranches = new List<string>() - { - "nodev" - }, - RemoteBranches = new List<string>() - { - "svn/dev", - "svn/branch2" - } - }; - - Options options = new Options() - { - Rebase = false - }; - - IFixer fixer = new Fixer(metaInfo, options, mock.Object, "", null, null); - - // Act - fixer.FixBranches(); - - // Assert - mock.Verify(f => f.Run("git", "checkout -b \"dev\" \"remotes/svn/dev\""), Times.Once()); - mock.Verify(f => f.Run("git", "branch --track \"dev\" \"remotes/svn/dev\"", out standardOutput, out standardError), Times.Once()); - } - - [Fact] - public void FixBranchesIsNotRebaseIsNotTrunkBranchTrackingNoWarningTest() - { - // Prepare - var mock = new Mock<ICommandRunner>(); - mock.Setup(f => f.Run("git", It.IsAny<string>())) - .Returns(0); - - string standardOutput = string.Empty; - string standardError = string.Empty; - mock.Setup(f => f.Run("git", "branch --track \"dev\" \"remotes/svn/dev\"", out standardOutput, out standardError)); - - MetaInfo metaInfo = new MetaInfo() - { - LocalBranches = new List<string>() - { - "nodev" - }, - RemoteBranches = new List<string>() - { - "svn/dev", - "svn/branch2" - } - }; - - Options options = new Options() - { - Rebase = false - }; - - IFixer fixer = new Fixer(metaInfo, options, mock.Object, "", null, null); - - // Act - fixer.FixBranches(); - - // Assert - mock.Verify(f => f.Run("git", "checkout \"dev\""), Times.Once()); - mock.Verify(f => f.Run("git", "branch --track \"dev\" \"remotes/svn/dev\"", out standardOutput, out standardError), Times.Once()); } #endregion