Skip to content

Vendor unmaintained github.com/pmezard/go-difflib#1708

Merged
brackendawson merged 26 commits intostretchr:masterfrom
brackendawson:internal-difflib
Sep 9, 2025
Merged

Vendor unmaintained github.com/pmezard/go-difflib#1708
brackendawson merged 26 commits intostretchr:masterfrom
brackendawson:internal-difflib

Conversation

@brackendawson
Copy link
Copy Markdown
Collaborator

@brackendawson brackendawson commented Mar 18, 2025

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 brackendawson requested a review from dolmen March 18, 2025 12:10
@brackendawson brackendawson changed the title Adopt support of github.com/pmezard/go-difflib Adopt internal support of github.com/pmezard/go-difflib Mar 18, 2025
@ccoVeille
Copy link
Copy Markdown
Collaborator

ccoVeille commented Mar 18, 2025

I love the idea of importing the lib and its history

But then, later, did you consider this also?

#1546

@brackendawson
Copy link
Copy Markdown
Collaborator Author

brackendawson commented Mar 18, 2025

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.

@dolmen dolmen added the internal/refactor Refactor internals with no external visible changes label May 25, 2025
@dolmen
Copy link
Copy Markdown
Collaborator

dolmen commented Jun 2, 2025

@Devourian What is your objection to this change?

@dolmen dolmen changed the title Adopt internal support of github.com/pmezard/go-difflib Vendor unmaintained github.com/pmezard/go-difflib Jun 4, 2025
@dolmen
Copy link
Copy Markdown
Collaborator

dolmen commented Jun 5, 2025

@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.

@brackendawson
Copy link
Copy Markdown
Collaborator Author

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 brackendawson marked this pull request as draft June 9, 2025 10:46
@brackendawson
Copy link
Copy Markdown
Collaborator Author

brackendawson commented Jun 9, 2025

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 brackendawson marked this pull request as ready for review June 9, 2025 10:56
@brackendawson brackendawson marked this pull request as draft August 29, 2025 14:49
@brackendawson brackendawson force-pushed the internal-difflib branch 2 times, most recently from 6d2505e to 16c6e3b Compare August 29, 2025 15:08
* Merge difflib into internal to preserve history.
* Remove unused exported functionality from difflib.
* Remove difflib from module's requirements.
* Document the origin of difflib in its godocs.
@brackendawson brackendawson marked this pull request as ready for review August 29, 2025 15:13
@brackendawson
Copy link
Copy Markdown
Collaborator Author

@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 brackendawson dismissed dolmen’s stale review September 9, 2025 06:17

As previously stated dolmen is happy with the code and wanted only a rebase: #1708 (comment) That rebase has been delivered.

@brackendawson brackendawson merged commit 297f37e into stretchr:master Sep 9, 2025
9 checks passed
@brackendawson brackendawson deleted the internal-difflib branch September 9, 2025 06:17
@chirag-painter
Copy link
Copy Markdown

Hi, Would it be possible to share an estimated public release date for this change?

@brackendawson
Copy link
Copy Markdown
Collaborator Author

I'd estimate around February.

@deepakmokashi
Copy link
Copy Markdown

Hello @brackendawson
Do you have an estimated release date for this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file internal/refactor Refactor internals with no external visible changes pkg-assert Change related to package testify/assert pkg-require Change related to package testify/require

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find an alternative for go-difflib