-
Notifications
You must be signed in to change notification settings - Fork 657
Format no format #4657
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
base: main
Are you sure you want to change the base?
Format no format #4657
Conversation
7048ae1
to
5e1c165
Compare
3510bed
to
8a331e5
Compare
8a331e5
to
3629aef
Compare
@@ -93,7 +93,7 @@ internal static partial class Common | |||
| # OR | |||
(?<member>[A-Za-z_][A-Za-z0-9_]*) # member/property name | |||
(?: # Optional format specifier | |||
:(?<format>[A-Za-z0-9\.\-,]+) # Colon followed by format string (no spaces, ?, or }), format cannot contain colon | |||
:(?<format>[A-Za-z0-9\.\-,;'"]+) # Colon followed by format string (including semicolons and quotes) |
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.
RCA
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.
RCA?
|
Apologies. Two passes is already more time than I had. The first pass was comfortable, the second's expanded in to assumptions that likely warrant a review & retrospect on regression pack coverage? Rollback & regroup the wise call? |
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.
Fantastic work! 🎉 Thank you so much for jumping on this so quickly, @9swampy! ❤️
# Three-section format: positive;negative;zero | ||
assembly-informational-format: "{Value:positive;negative;zero}" | ||
|
||
# Two-section format: positive;negative | ||
assembly-informational-format: "{Value:pos;neg}" |
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.
Could these last two examples be modified to be more practical and real-world relevant, with a line showing the result, as in the first code example?
- **Third section**: Used for zero values (optional) | ||
- **Empty quotes** (`''` or `""`) create empty output | ||
|
||
**Mixed Syntax:** You can combine legacy semicolon syntax with modern `??` fallback syntax in the same template. |
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.
How would ;;
and ??
be combined? Can we give a code example for this as well?
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.
I love the added tests! 🤩 Could we please have a test for the combination of ;;
and ??
as well?
@@ -1,7 +1,7 @@ | |||
using System.Globalization; | |||
using GitVersion.Formatting; | |||
|
|||
namespace GitVersion.Tests.Formatting; | |||
namespace GitVersion.Core.Tests.Formatting; |
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.
GitVersion.Core
should not be a namespace. :)
namespace GitVersion.Core.Tests.Formatting; | |
namespace GitVersion.Tests.Formatting; |
|
||
// Currently this will throw or behave unexpectedly | ||
// Should either throw meaningful error or handle gracefully | ||
Assert.Throws<ArgumentException>(() => template.FormatWith(semanticVersion, environment)); |
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.
I think it's a good practice to test the returned ArgumentException
to ensure that the right guard clause is throwing it. This just ensures that an ArgumentException
is being thrown anywhere by the code path, not necessarily by our own code.
@@ -1,6 +1,6 @@ | |||
using GitVersion.Formatting; | |||
|
|||
namespace GitVersion.Tests.Formatting; | |||
namespace GitVersion.Core.Tests.Formatting; |
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.
namespace GitVersion.Core.Tests.Formatting; | |
namespace GitVersion.Tests.Formatting; |
@@ -1,7 +1,7 @@ | |||
using System.Globalization; | |||
using GitVersion.Formatting; | |||
|
|||
namespace GitVersion.Tests.Formatting; | |||
namespace GitVersion.Core.Tests.Formatting; |
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.
namespace GitVersion.Core.Tests.Formatting; | |
namespace GitVersion.Tests.Formatting; |
@@ -93,7 +93,7 @@ internal static partial class Common | |||
| # OR | |||
(?<member>[A-Za-z_][A-Za-z0-9_]*) # member/property name | |||
(?: # Optional format specifier | |||
:(?<format>[A-Za-z0-9\.\-,]+) # Colon followed by format string (no spaces, ?, or }), format cannot contain colon | |||
:(?<format>[A-Za-z0-9\.\-,;'"]+) # Colon followed by format string (including semicolons and quotes) |
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.
RCA?
Fix legacy .NET composite format syntax
Description
Fixes legacy .NET format syntax
{CommitsSinceVersionSource:0000;;''}
that was outputting literal text instead of formatted values.LegacyCompositeFormatter
for semicolon-separated format sectionsValueFormatter
andRegexPatterns
to support semicolons??
syntaxBefore:
6.13.54-gv6-CommitsSinceVersionSource-0000-----
After:
6.13.54-gv60002
Related Issue
Fixes #4654
Motivation and Context
Legacy .NET semicolon format syntax stopped working, breaking existing GitVersion configurations.
How Has This Been Tested?
Added comprehensive test suites:
BackwardCompatibilityTests.cs
- 8 tests covering legacy format scenariosIssue4654Tests.cs
- 4 tests for the specific issueAll 12 new tests pass. No regression in existing tests.
Screenshots (if appropriate):
N/A
Checklist: