-
Notifications
You must be signed in to change notification settings - Fork 651
refactor: update remote branch handling in tests #4522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: update remote branch handling in tests #4522
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the handling of Git remotes in tests by introducing a new helper method (RenameRemote) to simplify renaming and by removing platform-specific skips for Windows.
- Added a RenameRemote extension method to centralize Git remote renaming logic.
- Updated multiple test cases to use the new helper, thereby increasing test coverage on Windows.
- Removed conditional skips for Windows to allow tests to run on all platforms.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/GitVersion.Core.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs | Updated remote renaming call and removed Windows skips. |
src/GitVersion.Core.Tests/IntegrationTests/VersionInMergedBranchNameScenarios.cs | Swapped direct remote renaming with the new extension method and removed Windows test skips. |
src/GitVersion.Core.Tests/IntegrationTests/VersionInCurrentBranchNameScenarios.cs | Replaced Renames with RenameRemote and removed Windows-specific skips. |
src/GitVersion.Core.Tests/IntegrationTests/RemoteRepositoryScenarios.cs | Updated remote renaming calls and removed Windows-dependent logic. |
src/GitVersion.Core.Tests/Extensions/GitRepositoryTestingExtensions.cs | Introduced the RenameRemote extension method for simplifying test remote renaming. |
d6e1172
to
520d23d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors remote branch handling in tests by introducing the new RenameRemote extension method and updating tests to use it, while also removing Windows-specific test skips to improve coverage.
- Introduces the RenameRemote extension in GitRepositoryTestingExtensions.cs.
- Updates several test files to use RenameRemote instead of the older Remotes.Rename.
- Removes platform-specific (Windows) test skips to enable broader test execution.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
VersionInBranchNameBaseVersionStrategyTests.cs | Uses RenameRemote in place of Remotes.Rename and removes Windows skip. |
VersionInMergedBranchNameScenarios.cs | Uses RenameRemote and removes Windows-specific skip. |
VersionInCurrentBranchNameScenarios.cs | Uses RenameRemote and removes Windows-specific skip. |
RemoteRepositoryScenarios.cs | Uses RenameRemote instead of Remotes.Rename; Windows skip removed. |
GitRepositoryTestingExtensions.cs | Adds the new RenameRemote extension method for simplifying remote renaming. |
64dc437
to
35d7418
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors remote branch handling in tests by introducing a new helper RenameRemote and updating existing tests to use it, while also removing platform-specific skips for Windows.
- Introduces the RenameRemote extension method in GitRepositoryTestingExtensions.cs
- Updates multiple integration and version strategy tests to use RenameRemote instead of the older Rename call
- Removes Windows-specific test skips to allow broader test execution across platforms
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
VersionInBranchNameBaseVersionStrategyTests.cs | Uses RenameRemote for renaming and removes Windows skip |
VersionInMergedBranchNameScenarios.cs | Replaces Rename call with RenameRemote and removes Windows skip |
VersionInCurrentBranchNameScenarios.cs | Updates remote renaming to use RenameRemote and removes Windows skip |
RemoteRepositoryScenarios.cs | Updates remote renaming to use RenameRemote and removes Windows skip |
GitRepositoryTestingExtensions.cs | Adds the new RenameRemote helper method to simplify remote renaming in tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors remote branch handling in tests by introducing a new helper method (RenameRemote) to simplify renaming Git remotes and eliminating Windows-specific test skips to improve cross-platform coverage.
- Added the RenameRemote extension method in GitRepositoryTestingExtensions.cs.
- Refactored multiple test cases to use RenameRemote instead of the older Remotes.Rename.
- Removed Windows-only test skips.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/GitVersion.Core.Tests/Extensions/GitRepositoryTestingExtensions.cs | Added the RenameRemote extension method with validation for renaming remotes. |
src/GitVersion.Core.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs | Updated test case to use RenameRemote and removed the conditional Windows test skip. |
src/GitVersion.Core.Tests/IntegrationTests/VersionInMergedBranchNameScenarios.cs | Updated test case to use RenameRemote and removed the conditional Windows test skip. |
src/GitVersion.Core.Tests/IntegrationTests/VersionInCurrentBranchNameScenarios.cs | Updated test case to use RenameRemote and removed the conditional Windows test skip. |
src/GitVersion.Core.Tests/IntegrationTests/RemoteRepositoryScenarios.cs | Updated test case to use RenameRemote and removed the conditional Windows test skip. |
Comments suppressed due to low confidence (2)
src/GitVersion.Core.Tests/Extensions/GitRepositoryTestingExtensions.cs:68
- [nitpick] Consider adding XML documentation to the 'RenameRemote' method to clarify its purpose, parameters, and the exceptions it may throw.
public static void RenameRemote(this LibGit2Sharp.RemoteCollection remotes, string oldName, string newName)
src/GitVersion.Core.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs:100
- [nitpick] The removal of the Windows platform skip enables broader test coverage; consider adding a comment noting that LibGit2Sharp compatibility on Windows has been verified to avoid potential issues.
public void CanTakeVersionFromNameOfRemoteReleaseBranch(string origin, string branchName, string expectedBaseVersion)
b358ce0
to
c11cd7a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors remote branch handling in tests by introducing a new helper method, RenameRemote, to simplify renaming Git remotes and by removing Windows-specific test skips to broaden test coverage.
- Introduced the RenameRemote extension method in GitRepositoryTestingExtensions.cs.
- Updated several integration and version strategy tests to use RenameRemote instead of the direct Remotes.Rename call.
- Removed platform-specific skips for Windows from the tests.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/GitVersion.Core.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs | Removed Windows skips and updated rename call to use RenameRemote. |
src/GitVersion.Core.Tests/IntegrationTests/VersionInMergedBranchNameScenarios.cs | Updated rename call to use RenameRemote and removed Windows skip. |
src/GitVersion.Core.Tests/IntegrationTests/VersionInCurrentBranchNameScenarios.cs | Updated rename call to use RenameRemote and removed Windows skip. |
src/GitVersion.Core.Tests/IntegrationTests/RemoteRepositoryScenarios.cs | Updated rename call to use RenameRemote and removed Windows skip. |
src/GitVersion.Core.Tests/Extensions/GitRepositoryTestingExtensions.cs | Added the new RenameRemote extension method to simplify remote renaming. |
Comments suppressed due to low confidence (1)
src/GitVersion.Core.Tests/Extensions/GitRepositoryTestingExtensions.cs:79
- The RenameRemote helper currently adds a new remote using only the URL, which does not preserve additional remote configuration such as fetch refspecs. If any tests rely on these settings, consider enhancing the method to copy over these configurations as well.
remotes.Add(newName, remotes[oldName].Url);
Thank you @arturcic for your contribution! |
This pull request introduces a new helper method,
RenameRemote
, to simplify renaming Git remotes in tests and refactors existing test cases to use this method. Additionally, it removes platform-specific test skips for Windows, enabling broader test coverage.New Helper Method:
RenameRemote
extension method toLibGit2Sharp.RemoteCollection
for renaming Git remotes more concisely. (src/GitVersion.Core.Tests/Extensions/GitRepositoryTestingExtensions.cs
)Refactoring Test Cases:
Remotes.Rename
with the newRenameRemote
method in multiple test cases to improve code readability and reuse. (src/GitVersion.Core.Tests/IntegrationTests/RemoteRepositoryScenarios.cs
,src/GitVersion.Core.Tests/IntegrationTests/VersionInCurrentBranchNameScenarios.cs
,src/GitVersion.Core.Tests/IntegrationTests/VersionInMergedBranchNameScenarios.cs
,src/GitVersion.Core.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs
) [1] [2] [3] [4]Test Coverage Enhancements:
src/GitVersion.Core.Tests/IntegrationTests/RemoteRepositoryScenarios.cs
,src/GitVersion.Core.Tests/IntegrationTests/VersionInCurrentBranchNameScenarios.cs
,src/GitVersion.Core.Tests/IntegrationTests/VersionInMergedBranchNameScenarios.cs
,src/GitVersion.Core.Tests/VersionCalculation/Strategies/VersionInBranchNameBaseVersionStrategyTests.cs
) [1] [2] [3] [4]