-
Couldn't load subscription status.
- Fork 79
Fix JSON parsing in tasks when '{' is in the GitVersion output #1792
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?
Fix JSON parsing in tasks when '{' is in the GitVersion output #1792
Conversation
|
@SimplyAName thanks for putting that much effort in this, I will hopefully have a look soon on the changes |
|
Awesome, thanks. The main code is working, just having some issues with my tests. |
|
All tests have been fixed now. Had to modify one of the existing tests that checks the SHA of the commit. Was failing due to the pipeline merging master in before running. This resulted in a new commit and hash being created, which did not match the branch being checked by GitVersion. Updated to get the latest commit without merge commits |
|
@SimplyAName please use rebase onto |
a938242 to
78402aa
Compare
|
@arturcic I've rebased my branch and force-pushed to override the merge commits. Lmk if anything needs fixing |
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.
LGTM!
|
@SimplyAName please rebase your changes once again and fix the SonarCloud issue: I will accept the change for this release, but I think in the next major release we need to implement it in a more reliable way than parsing the output. There is and Anyway thanks for the time and effort. |
1498904 to
7fe7348
Compare
|
@SimplyAName I applied the changes myself and squashed the commits into 2 atomic commits |
fixes the gitversion json parsing, including an extractor function to handle branch names with brackets adds a helper function to find all indexes of a character in a string adds tests for the json extractor to cover different branch names
7fe7348 to
e6808cd
Compare
|
I have not contributed here before, so please let me know if there's anything I need to do/fix.
I've done my best to match existing styling and have included some unit tests for my change.
TLDR:
This PR is mainly to fix #1711. I've been running into the same issue on my own pipelines and have tracked down the root cause to output parsing in the tasks.
The error occurs when a '{' character exists anywhere in the GitVersion output object, such as in a branch name. This caused the old parsing function to get an invalid JSON object, as the last '{' didn't belong to the JSON object, just the property string.
To fix this, I've added a function that will start with the old search (last '{' and '}') but then expand to the next '{' character and check if the JSON object is valid again. This continues till a valid object is found or sets the task to failed if it is unable to find one.
I've also included a new section on getting set up with this project in the README. I faced some issues setting it up for the first time, so I included some of the basic things I was missing. If the README changes should be in a separate PR, let me know