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

Newline at end of text line in contents property is not included when appended to wiki file #988

Closed
msorokowski opened this issue Mar 26, 2021 · 6 comments · Fixed by #989

Comments

@msorokowski
Copy link

Describe the bug
I'm using the WIKIUpdater to append content to an existing wiki page. The content is specified in the contents property (instead of reading from a file).

The newline at the end of a text line in the contents property is not included when it's appended to the wiki page content.

Thus, a newline is not included on the last line of the appended content in the wiki page. So when this task is executed a couple of times, it will end up appending the content to the end of the last line instead of the next line since the last line will not have a newline .

Here's a screenshot of the YAML (displaying CTRL characters to show the CR LFs). This example has a newline at the end of the desired text line to append, plus a newline on the next line (for good measure, but is expected to be excluded since the literal style with clip should maintain a single newline at the end of the string).

image

However, the newline is not added to the wiki page content.

Here's a screenshot of the wiki page content (and preview) after executing the task 3 times:

image

Expected behavior
Expecting the newline at the end of the content line to be copied to the wiki page content.

Where is the issue seen:

  • Azure DevOps Services (VSTS)
@rfennell
Copy link
Owner

I will have to look into that, but wonder if it is 'feature' of how multi-line parameters are parsed

@msorokowski
Copy link
Author

I did another test... If there's 2 lines containing text, the newline at the end of the first line is copied. The trailing spaces and newlines after the last line of text are clipped.

image

So "Line 2" does end up on another line. But the next time it's executed, "Line 1" is appended to the end of the previous "Line 2".

Here's the raw markdown and preview of the results after 2 executions:

image

@rfennell
Copy link
Owner

I think that supports my assumption there is some trimming of the text in a multiline YAML. I think the best option is to add a new parameter to the task to optionally insert a new line between appended/prepended files.

@msorokowski
Copy link
Author

I guess there’s a few use cases out there that might warrant prepending a newline before the content, and/or appending a newline after the content.

Something for you to think about, but I think one or the other would resolve the issue I’ve encountered.

@rfennell
Copy link
Owner

The updated task is being released as 1.24.3. There is now an extra parameter insertLinefeed, if set to true an extra linefeed is added between the old and new content when appending or pretending content.

- task: WikiUpdaterTask@1
  inputs:
    ... other params
    repo: 'dev.azure.com/richardfennell/Git%20project/_git/Git-project.wiki'
    replaceFile: false
    appendToFile: true
    insertLinefeed: true
    dataIsFile: false
    contents: |
      - $(build.buildnumber)
      - Line 1
      - Line 2

@msorokowski
Copy link
Author

Thanks! I just tested the new feature and all is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants