Use GitVersion /outputfile instead of parsing JSON from stdout#1815
Use GitVersion /outputfile instead of parsing JSON from stdout#1815
/outputfile instead of parsing JSON from stdout#1815Conversation
/outputfile instead of parsing JSON from stdout
|
@copilot the |
|
|
@copilot the newly added tests are failing on windows: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯ FAIL src/tests/tools/gitversion/tool.spec.ts > GitVersionTool > readGitVersionOutput > should throw error for invalid JSON file |
Fixed in 2022b69. Tests now use |
|
@SimplyAName mind do check these changes? |
2022b69 to
e55d155
Compare
Co-authored-by: arturcic <1760506+arturcic@users.noreply.github.com>
Co-authored-by: arturcic <1760506+arturcic@users.noreply.github.com>
Co-authored-by: arturcic <1760506+arturcic@users.noreply.github.com>
Co-authored-by: arturcic <1760506+arturcic@users.noreply.github.com>
Co-authored-by: arturcic <1760506+arturcic@users.noreply.github.com>
Adds debug logs for reading and writing GitVersion variables to improve traceability.
e55d155 to
e9431f9
Compare
|
|
Thank you @Copilot for your contribution! |
|
LGTM Could have added a flag to use JSON output if we are keeping the old JSON processing, but can add it if someone has an issue etc |
|
🎉 This issue has been resolved in version v4.2.0 🎉 Your GitReleaseManager bot 📦🚀 |





Summary: Use JSON file instead of parsing output from GitVersion ✅
This PR implements the enhancement requested in the issue to use GitVersion's
/outputfileargument instead of parsing JSON from stdout. This approach is more future-proof and reliable.Implementation Complete ✅
/outputfileargumentgetExecuteArgumentsto add/outputfileparameter with temp file pathexecuteJsonto include outputFile in resultprocessGitVersionOutputto read JSON from filereadGitVersionOutputmethod to read and parse JSON file/output filewith/outputfileinstead of/output jsonChanges Made
1. tool.ts - Core Implementation
path,fs/promises, andcryptoexecuteJson()to:crypto.randomUUID()to prevent collisionsgetExecuteArguments()outputFilepropertygetExecuteArguments()to accept optionaloutputFileparameter:outputFileis provided: Use/output file /outputfile {filename}outputFileis NOT provided: Use/output json(backward compatible)readGitVersionOutput()method to:GitVersionOutputtype2. runner.ts - Processing Logic
processGitVersionOutput()to be async and accept result with optionaloutputFilepropertygetErrorMessage()- Safely extract error messageshandleOutputError()- Centralized error handling logic3. tool.spec.ts - Test Coverage
fs/promises,os, andpathmodulesgetExecuteArguments()/output file /outputfilearguments when output file is provided/output jsonarguments when output file is NOT providedreadGitVersionOutput()successfully reads and parses JSON filereadGitVersionOutput()throws error for invalid JSONos.tmpdir()andpath.join()for cross-platform compatibilityCorrect GitVersion CLI Usage
When writing to file:
When writing to stdout:
Benefits
✅ More Reliable: Direct file reading instead of parsing stdout with potential log messages
✅ Future-Proof: Uses official GitVersion CLI feature designed for this purpose
✅ Backward Compatible: Maintains fallback to stdout parsing if needed
✅ Clean: Automatically cleans up temporary files after reading
✅ Secure: Uses
crypto.randomUUID()for unique file names to prevent collisions✅ Cross-Platform: Tests work on Linux, macOS, and Windows
✅ Well-Tested: 4 new tests covering file-based functionality
Test Results
Security Summary
No security vulnerabilities were introduced by these changes. CodeQL analysis found 0 alerts.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.