Skip to content
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

fix: WriteLineToFile truncates file when opening #1916

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

mcwarman
Copy link
Member

@mcwarman mcwarman commented Feb 7, 2024

This ensures that when a line is replaced if the value is shorter than the existing line the remaining values are not left in the buffer.

Fix #1915

Test

To test this pull request, you can run the following commands:

cd pkg/plugins/resources/file
go test

test.yaml

targets:
  updateSyncServiceVersion:
    name: Bump Sync Service version
    kind: file
    disablesourceinput: true
    spec:
      file: file.txt
      line: 1
      content: org.alfresco.services.sync:service-sync:${ARTIFACT_VERSION:-5.0.0-A13}:jar
  updateDeviceSyncRepoVersion:
    name: Bump Device Sync Repo version
    kind: file
    disablesourceinput: true
    spec:
      file: file.txt
      line: 2
      content: org.alfresco.services.sync:alfresco-device-sync-repo:${ARTIFACT_VERSION:-5.0.0-A13}:amp

file.txt

org.alfresco.services.sync:service-sync:${ARTIFACT_VERSION:-5.0.1-SNAPSHOT}:jar
org.alfresco.services.sync:alfresco-device-sync-repo:${ARTIFACT_VERSION:-5.0.0-SNAPSHOT}:amp

This ensures that when a line is replaced if the value is shorter than the existing line the remaining values are not left in the buffer.

ref: updatecli#1915
Copy link
Member

@olblak olblak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this issue

@olblak
Copy link
Member

olblak commented Feb 7, 2024

Thanks for the example, I just tested manually and your fix works as expected

@olblak olblak modified the milestone: 0.73.0 Feb 7, 2024
@olblak olblak added the bug Something isn't working label Feb 7, 2024
@olblak olblak merged commit be0686e into updatecli:main Feb 7, 2024
6 checks passed
@mcwarman mcwarman deleted the fix/truncate-file-on-line-replace branch February 7, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected trailing contents with file target and content targeting a specific line
2 participants