Skip to content

Not able to parse some diffText #107

@lomse

Description

@lomse

Hi All,
Thanks for this amazing library.
I'm having hard time understanding why it is not able to parse the strings below:

@@ -7,6 +7,9 @@ stages:
 #  - scan
   - deploy
 
+include:
+  - template: depl/config.yml
+
 unit tests:
   image: maven:3-jdk-8
   stage: test
@@ -7,6 +7,9 @@ stages:
 #  - scan
   - deploy
 
+include:
+  - template: depl/config-2.yml
+
 unit tests:
   image: maven:3-jdk-8
   stage: test

I keep getting the error as shown on the screenshot below:

Screenshot 2020-12-03 at 4 27 11 PM

What am I missing please? Below is my implementation

type ChangesProps = {
  diffs: DiffType[]
}

export const Changes: React.FC<ChangesProps> = ({ diffs }) => {

  return (
    <React.Fragment>
      {diffs.map((diffObj, index) => {
        const diffText = diffObj.diff;
        console.log(diffText)
        const files = parseDiff(diffText) // Error thrown here.

        console.log({files})

        const renderFile = ({ oldRevision, newRevision, type, hunks }) => (
          <Diff key={oldRevision + '-' + newRevision} viewType="unified" diffType={type} hunks={hunks}>
            {hunks => hunks.map(hunk => <Hunk key={hunk.content} hunk={hunk} />)}
          </Diff>
        )

        return (
          <div key={index}>
            {files.map(renderFile)}
          </div>
        )
      })}
    </React.Fragment>
  )
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions