dropbox / dependency-guard

A Gradle plugin that guards against unintentional dependency changes.
Apache License 2.0
416 stars 15 forks source link

Fix diff text lines missing #95

Closed SimonMarquis closed 1 year ago

SimonMarquis commented 1 year ago

The \n was added only if the first condition was false because of if/else priorities.

if (a) {
  /**/
} else if (b) {
  /**/
} else {
  /**/
} + x

is in fact executed as

if (a) {
  /**/
} else {
    if (b) {
      /**/
    } else {
      /**/
    } + x
}

Closing #94

SimonMarquis commented 1 year ago

We probably should add tests to avoid future regressions.

handstandsam commented 1 year ago

| "We probably should add tests to avoid future regressions."

What isn't covered? I think because we're on 0.5.x and haven't cut it yet, ideally we should be adding tests in now. I felt like 0.4.x ended up being pretty crazy running around trying to fix config cache, so the more tests the better!

--

Thank you for the PR!

SimonMarquis commented 1 year ago

The current tests were asserting on the Gradle exception message.

SimonMarquis commented 1 year ago

The new version now uses StringBuilder, which makes new lines automatically handled. Also, I removed the dependency of diffTextWithPlusAndMinusWithColor on diffTextWithPlusAndMinus. They now only rely on diffLines. This makes it more straightforward, as we no longer have to check for "empty" lines and unexpectedly produce a double line break.

handstandsam commented 1 year ago

Sounds good. Is this ready to merge? Looked fine.

SimonMarquis commented 1 year ago

Yup, ready to be merged 👌