Skip to content

Conversation

RussKie
Copy link
Member

@RussKie RussKie commented Oct 29, 2023

Proposed changes

  • Move tests to match folder structure
  • Sort implementations and tests lexicographically
  • Move GitModule.Push* commands
  • Move GitModule.Commit commands

Merge strategy

❗ DO NOT SQUASH


✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned RussKie Oct 29, 2023
@gerhardol
Copy link
Member

Some tests like those in UnitTests/GitCommands.Tests/Git/CommandsTests.cs seem to be removed. Is that intentional?

@RussKie
Copy link
Member Author

RussKie commented Oct 29, 2023 via email

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just looks like lots of tests had been removed in the first commit. That is because testcases have been moved out to a new file:

--- a/UnitTests/GitCommands.Tests/Git/Commands/GitCommandHelpersTest.cs
+++ b/UnitTests/GitCommands.Tests/Git/Commands/GitCommandHelpersTest.cs

--- a/UnitTests/GitCommands.Tests/Git/Commands/GitCommandHelpersTest.cs
+++ b/UnitTests/GitCommands.Tests/Git/CommandsTests.cs

image


But what is the criterion for this split of GitCommandHelpersTest.cs?


Move tests to match folder structure

For technical reasons (avoiding ambiguity), the namespace name was tinkered.

namespace GitCommandsTests.Git_Commands
means
namespace GitCommandsTests.Git.Commands

(If you think this is a problem, we should rather switch to namespace UnitTests.GitCommands_.Git_.Commands_ for instance.)

Hence the "git tag" tests should not be moved up out of the folder UnitTests/GitCommands.Tests/Git/Commands/:

--- a/UnitTests/GitCommands.Tests/Git/Commands/GitCreateTagCmdTests.cs
+++ b/UnitTests/GitCommands.Tests/Git/CommandsTests.CreateTag.cs
@@ -4,8 +4,7 @@
 
 namespace GitCommandsTests.Git_Commands
 {
-    [TestFixture]
-    public sealed class GitCreateTagCmdTests
+    partial class CommandsTests

🤔 Test names have lost the relation to the command:

Before After
image image

@RussKie
Copy link
Member Author

RussKie commented Oct 30, 2023

But what is the criterion for this split of GitCommandHelpersTest.cs?

It was easier to rename GitDeleteBranchCmdTests.cs to CommandsTests.DeleteBranch.cs than to move the content and make the review harder. The same applies to CommandsTests.CreateTag.cs.
These files contain tests for Commands.DeleteBranch and Commands.CreateTag respectively that are defined in GitCommands/Git/Commands.cs; and the naming/placement reflect the location of the shippable code.

@RussKie
Copy link
Member Author

RussKie commented Oct 30, 2023

Test names have lost the relation to the command:

Before After
image image

This means the original tests were poorly named, and I didn't pay much attention to those. My goal was to consolidate the tests and place those in the correct folder structure.

@RussKie
Copy link
Member Author

RussKie commented Oct 30, 2023

It just looks like lots of tests had been removed in the first commit. That is because testcases have been moved out to a new file:

--- a/UnitTests/GitCommands.Tests/Git/Commands/GitCommandHelpersTest.cs
+++ b/UnitTests/GitCommands.Tests/Git/Commands/GitCommandHelpersTest.cs

--- a/UnitTests/GitCommands.Tests/Git/Commands/GitCommandHelpersTest.cs
+++ b/UnitTests/GitCommands.Tests/Git/CommandsTests.cs

image

GitCommandHelpersTest contain tests for commands defined in GitModule class. Those have to be moved out (#11308 is contributing to that. However, there are few methods like FetchCmd and PullCmd that rely on GitModule's internals, and I'm yet to figure out how to break that dependency); and once those are moved out the test will be moved out from GitCommandHelpersTest.cs as well.

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@RussKie RussKie force-pushed the move_Cmd_from_GitModule branch from 3a9e2fc to 719b950 Compare October 31, 2023 12:32
@RussKie RussKie merged commit 51687c5 into gitextensions:master Nov 2, 2023
@RussKie RussKie deleted the move_Cmd_from_GitModule branch November 2, 2023 13:22
@ghost ghost added this to the vNext milestone Nov 2, 2023
{ !string.IsNullOrEmpty(author), $"--author=\"{author?.Trim().Trim('"')}\"" },
{ gpgSign && string.IsNullOrWhiteSpace(gpgKeyId), "-S" },
{ gpgSign && !string.IsNullOrWhiteSpace(gpgKeyId), $"-S{gpgKeyId}" },
{ useExplicitCommitMessage, $"-F \"{GetGitExecPath(Path.Combine(GetGitDirectory(), "COMMITMESSAGE"))}\"" },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change prevents commits in WSL.
Only in master.
Not sure if other commands are affected, refactoring moving code are hard to review.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only real change. A comment would have been good. How does this make it work in WSL?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path is in the format for gitexec, ie in wsl format.
Added for a few commands, manually identified.

This was a series of changes, I did not see any related changes. So hopefully the only issue.

The transformation will have to be added to the caller of commands arguments where module is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants