testify icon indicating copy to clipboard operation
testify copied to clipboard

Vendor unmaintained github.com/pmezard/go-difflib

Open brackendawson opened this issue 8 months ago • 8 comments

Summary

Bring the un-maintained github.com/pmezard/go-difflib/difflib library into testify and adopt support of the package.

Changes

  • Move github.com/pmezard/go-difflib/difflib package to .../internal/difflib so that it cannot be imported by other modules.
  • Copy internal/difflib into testify, preserving all git history, and preserving the difflib license.
  • Remove unused functions from internal/difflib.
  • Remove github.com/pmezard/go-difflib from testify's requirements.

Motivation

Difflib is explicitly unmaintained but depended on by testify.

Related issues

Closes #1159

brackendawson avatar Mar 18 '25 12:03 brackendawson

I love the idea of importing the lib and its history

But then, later, did you consider this also?

https://github.com/stretchr/testify/pull/1546

ccoVeille avatar Mar 18 '25 21:03 ccoVeille

I'm aware, the idea of changing the library used for this gives me some concern. It's not so bad because it's not actually used for any comparisons. But it does change the diff and it's likely there will be cases where the change is a negative. If this was on a v2 boundary I'd be less hesitant.

It's also another library which might be considered unsupported by some. I usually don't share the view but a lot of corporations consider projects which don't have recent work on them to be de-facto unsupported. I sometimes consider these to be "stable", but an aim of the current maintenance of testify is to make it so that users with some requirement to use only supported software don't need to re-write all their tests to remove testify.

This PR is one of a few potential options. Substantive discussion will decide which is used.

brackendawson avatar Mar 18 '25 23:03 brackendawson

Thanks a lot for handling this. When do you expect to merge this?

mhussein avatar May 20 '25 16:05 mhussein

This is the right thing to do.

dolmen avatar May 22 '25 09:05 dolmen

@Devourian What is your objection to this change?

dolmen avatar Jun 02 '25 12:06 dolmen

@brackendawson I'm ok with the current code.

However I would prefer if we could have a clean branch rebased on top of master at the time of merge, for a cleaner history.

I've attempted git rebase -i -r --onto origin/master 7c367bb7bc7dad2d8b17921a604157dc27ebe06f internal-difflib, but a problem remains as the reference to the external difflib remains in go.mod. We would have to edit the merge commit, but I haven't been able to do it so far.

dolmen avatar Jun 05 '25 10:06 dolmen

I'll make a clean version. Also would appreciate not changing the titles of PRs unless it's necessary, it makes it harder to keep track of things that are in progress.

brackendawson avatar Jun 09 '25 08:06 brackendawson

I don't think the rebase tooling in git supports rebasing across unrelated histories, so the only way to make a version of this branch without another merge commit is to repeat this procedure from scratch, which I'm not going to do. I think the best way forward is to merge this with a merge commit, as has been done with many other PRs in this repo.

brackendawson avatar Jun 09 '25 10:06 brackendawson

@dolmen or @ccoVeille I've re-based this PR, it's not trivial to do so I'd appreciate it if you could consider re-approval soon.

brackendawson avatar Aug 29 '25 15:08 brackendawson