gemini-code-assist[bot] commented on code in PR #18717:
URL: https://github.com/apache/tvm/pull/18717#discussion_r2774179933
##########
ci/scripts/jenkins/open_docker_update_pr.py:
##########
@@ -150,7 +150,7 @@ def latest_tlcpackstaging_image(source: str) ->
Optional[str]:
# Re-generate the Jenkinsfiles
command = f"python3 {shlex.quote(str(GENERATE_SCRIPT))}"
- content = "\n".join(content)
+ content = "".join(content)
Review Comment:

This change from `"\n".join(content)` to `"".join(content)` correctly fixes
the original problem of double newlines. However, this reveals another issue in
the surrounding code.
The `new_line` values in the `replacements` dictionary are constructed
without a trailing newline on line 147. The `old_line` keys, which come from
`f.readlines()`, do have a trailing newline.
The call to `content.replace(old_line, new_line)` on line 155 will therefore
replace a line *with* a newline with a line *without* one. This will cause the
updated line to be merged with the following line, resulting in a malformed
file, which is what this PR originally aimed to prevent.
A complete fix would involve also ensuring the replacement string includes a
newline. The most direct way is to adjust line 147:
```python
new_line = f' "tag": "{new_image}",\n'
```
A more robust solution would be to refactor the logic to build a new list of
lines instead of performing string replacement on the entire file content,
which can be brittle. Since that's a larger change, I'd recommend at least
ensuring the newlines are handled correctly to fully resolve the file
corruption issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]