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

HTML Reporter: New Diff using Google's Diff-Patch-Match Library #772

Closed

Conversation

gauravmittal1995
Copy link
Contributor

Uses google's Diff Patch Match Library to replace the current diff algorithms.

Solves: #348

Discussed (and screenshots) in #764

@leobalter @jzaefferer Please Review

@leobalter
Copy link
Member

This project uses a Apache 2.0 License. Regarding that, I believe the best approach would be to have an exposed copy of that library including its license.

@gauravmittal1995
Copy link
Contributor Author

@leobalter The library is big and contains a lot of things not required. Doesn't this come under the modification of code?

@scottgonzalez
Copy link
Contributor

Section 4a of the license:

You must give any other recipients of the Work or
Derivative Works a copy of this License; and

*
* More Info:
* http://ejohn.org/projects/javascript-diff-algorithm/
* https://code.google.com/p/google-diff-match-patch/
Copy link
Member

Choose a reason for hiding this comment

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

It might be possible to paste the license inline here, I'm not sure about it. Would you confirm this, @scottgonzalez?

@scottgonzalez
Copy link
Contributor

@gauravmittal1995
Copy link
Contributor Author

@scottgonzalez Its from that file. Converted all var to camelcase, grouped the variables, removed unnecessary functions.

@scottgonzalez
Copy link
Contributor

Its from that file. Converted all var to camelcase, grouped the variables, removed unnecessary functions.

😖 Sounds pretty terrible for future upgrades.

Besides the removal of unused functions, why would you even do that?

@scottgonzalez
Copy link
Contributor

I guess the idea is that we'll never upgrade because the project is no longer active?

@gauravmittal1995
Copy link
Contributor Author

@scottgonzalez Which project?

@scottgonzalez
Copy link
Contributor

The one you just copy and pasted...

@gauravmittal1995
Copy link
Contributor Author

@scottgonzalez u mean the diff-patch-match?
Also the unused functions are the ones for patches and matching.

@scottgonzalez
Copy link
Contributor

@scottgonzalez u mean the diff-patch-match?

Yes. I assume the thought is that the project is dead and we'll never need to update, so changing source is ok.

@gauravmittal1995
Copy link
Contributor Author

@scottgonzalez So should we include the license as @leobalter suggested?

@scottgonzalez
Copy link
Contributor

It's a fairly lengthy license to include in source. I'd prefer if it were in its own file like we do in every other project.

@gauravmittal1995
Copy link
Contributor Author

@scottgonzalez SO create a new file with a licence file in it? Should i place it in the external/jsdiff folder??

@scottgonzalez
Copy link
Contributor

Yes, though we should probably rename the file and directory since it no longer contains jsdiff.

@gauravmittal1995
Copy link
Contributor Author

@scottgonzalez yes ... thanks :)

@gauravmittal1995
Copy link
Contributor Author

@scottgonzalez Should we name it diff-match-patch??

@scottgonzalez
Copy link
Contributor

Well, with how heavily modified it is, I'd personally move it back to src/diff.js and update our license, but that's really a question for @jzaefferer.

@gauravmittal1995
Copy link
Contributor Author

@scottgonzalez ok ... i will wait for @jzaefferer to reply before making any changes

@jzaefferer
Copy link
Member

The last commit is from 2012, and while issues are still getting reported, they're not getting addressed. With that in mind I agree with Scott that the project is effectively dead. Considering the modifications I also agree that it makes sense to deal with this as source code, putting it into src/diff.js.

I'm not exactly sure how to deal with the license in this case, though I noticed that the Apache 2.0 license appendix provides a brief version to put in source code, which seems pretty reasonable:

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

On the implementation/testing side, we should do more testing, especially with this in mind (compare html/xml strings): https://code.google.com/p/google-diff-match-patch/wiki/Plaintext

@scottgonzalez
Copy link
Contributor

Right, that's basically what's in the original source. My first suggestion was going to be to keep that intact, but the code looked so different that I instead asked where the code came from.

The Apache 2.0 license has the following clause:

You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works

I'm not sure how literal this needs to be followed, i.e., must we copy the existing license block verbatim or can we just reproduce the same details in our own format or by following the standard template? I highly doubt this has been tried in court, so it's going to be up for debate. @StevenAyr what do you suggest?

The other clause we need to address is:

You must cause any modified files to carry prominent notices stating that You changed the files

@StevenAyr
Copy link

I don't think anyone would ever sue because you put the license in the License file and didn't leave it inline, but if it's just as easy to leave it inline that may ultimately be easier and cleaner than adding something new to the License file anyways. Ultimately, the biggest consideration is probably just keeping things uniform across all projects and files, so go with the method that's otherwise used.

As for the modification notice, this too can live either in the license file or inline, depending on what you guys think is the best practice. Again though, it may be cleanest to put something inline along the lines of:
"This file is a modified version of ..., modifications are licensed as more fully set forth in LICENSE.md. The original source of ... is attributable and licensed as follows..."

@jzaefferer
Copy link
Member

Adding a notification to the source file and the proper license (or at least what the appendix suggests) to LICENSE.txt sounds good to me.

How is this for the notification?

This file is a modified version of google-diff-match-patch's JavaScript implementation (https://code.google.com/p/google-diff-match-patch/source/browse/trunk/javascript/diff_match_patch_uncompressed.js), modifications are licensed as more fully set forth in LICENSE.txt. The original source of google-diff-match-patch is attributable and licensed as follows:

Copyright 2006 Google Inc.
http://code.google.com/p/google-diff-match-patch/

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@StevenAyr
Copy link

I think it's probably best to go ahead and put the full appendix in there, just to be technically compliant.

@jzaefferer
Copy link
Member

I've updated my comment above, to include the full appendix. How's that?

@gauravmittal1995
Copy link
Contributor Author

@leobalter @jzaefferer Please review

* limitations under the License.
*
* More Info:
* https://code.google.com/p/google-diff-match-patch/
Copy link
Member

Choose a reason for hiding this comment

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

http://google-opensource.blogspot.com/2015/03/farewell-to-google-code.html

This came up today, what should we do with the Google Code links when it expires?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe file an issue on the project to ask about migration, and contact the author directly as well? As long as its unclear if they'll host a proper archive, getting him to migrate to another platform would be best.

Copy link
Member

Choose a reason for hiding this comment

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

People on twitter are asking them to keep an archive, but so far on their agenda:

January 25, 2016 - The project hosting service is closed. You will be able to download a tarball of project source, issues, and wikis. These tarballs will be available throughout the rest of 2016.

So far, I'll give my ok to these lines here and we can update it later if we have any other resolution from Google Code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Apache License, Version 2.0 doesn't require us to link to the original source or even provide the original Source form with the distribution. I'd say we don't need to spend any more time worrying about this. If you want to ensure the original Source form is always available, just provide a copy in the external directory.

the terms above.
All files located in the node_modules are externally maintained
libraries used by this software which have their own licenses; we
recommend you read them, as their terms may differ from the terms above.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jzaefferer Is this correct??

Copy link
Member

Choose a reason for hiding this comment

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

Missing "directory", should be "All files located in the node_modules directory are [...]"

@gauravmittal1995
Copy link
Contributor Author

@jzaefferer Please Review

*
* Usage: QUnit.diff(expected, actual)
*
* QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) === "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
Copy link
Member

Choose a reason for hiding this comment

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

Is this example still correct? The new diff might output something else here.

@jzaefferer
Copy link
Member

Pretty close!

@gauravmittal1995
Copy link
Contributor Author

@jzaefferer Please Review.

@leobalter
Copy link
Member

Awesome! LGTM

@gauravmittal1995
Copy link
Contributor Author

Fixed the License file statement, and the example in the comment of src/diff.js

@leobalter
Copy link
Member

Fixed the License file statement, and the example in the comment of src/diff.js

Did you do this in a new commit without pushing it?

@gauravmittal1995
Copy link
Contributor Author

no, i did this in the last commit that i pushed, gauravmittal1995@39b40ff (The fifth commit in this PR). Just mentioning the changes done in the commit

@jzaefferer
Copy link
Member

@gauravmittal1995 mostly off-topic: When are you going to submit your proposal through the GSoc site?

@gauravmittal1995
Copy link
Contributor Author

@jzaefferer I am in the middle of my Mid Semester Exams which will last till friday. I have made a profile at the Melange Site. I mostly will submit my proposal by sunday. Any thoughts??

@jzaefferer
Copy link
Member

That's fine, just wouldn't want you to miss the deadline (27th).

@gauravmittal1995
Copy link
Contributor Author

@jzaefferer Yes, Thanks :) ... My exams just got over. Will submit it by tomorrow (Saturday).

@leobalter
Copy link
Member

Merging it, the only other point is, a lot of other diff PRs might be affected.

Now that we have a more consistent diff library, it's also good to create tests for it, I'll save this in a new issue.

leobalter pushed a commit to leobalter/qunit that referenced this pull request Mar 26, 2015
leobalter pushed a commit to leobalter/qunit that referenced this pull request Mar 26, 2015
@leobalter leobalter closed this in 799a00f Mar 26, 2015
@jzaefferer jzaefferer added this to the 1.18.0 milestone Apr 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants