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

Add new patcher: git 'init' patcher #471

Merged
merged 4 commits into from Feb 13, 2023
Merged

Add new patcher: git 'init' patcher #471

merged 4 commits into from Feb 13, 2023

Conversation

cweagans
Copy link
Owner

@cweagans cweagans commented Feb 12, 2023

Description

git has historically been the most reliable mechanism for applying patches. Unfortunately, it doesn't work at all when the target directory isn't a git repo. This pull request adds a new patcher that creates a fake (minimal) git repository in the target directory, uses git to apply the patch, and then cleans up the fake git repo.

Related tasks

  • Documentation has been updated if applicable
  • Tests have been added
  • Does not break backwards compatibility OR a BC break has been discussed in the related issue(s).

Other notes

@deviantintegral I'm very curious about your thoughts on this one since you did most of the original debugging around why git was misbehaving. (composer install then ./vendor/bin/codecept run tests/acceptance/ApplyGitPatchFromWebUsingInitCept.php --debug if you want to play with this locally) -- I merged #472 but we can revert if needed.

If this approach works, I'm really considering #472 as a path forward. Git handles a lot of things that people have asked for over the year. It's also a lot easier to support -- "Go install git" is easier to communicate than "Go install patch... no, the patch that came with your system is unusable and you need to install this other thing that is named exactly the same but provides different functionality"

@coveralls
Copy link

coveralls commented Feb 12, 2023

Pull Request Test Coverage Report for Build 4158688379

  • 18 of 18 (100.0%) changed or added relevant lines in 3 files are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.8%) to 85.37%

Files with Coverage Reduction New Missed Lines %
src/Patcher/GnuPatchPatcher.php 7 63.16%
Totals Coverage Status
Change from base Build 4155475134: -0.8%
Covered Lines: 496
Relevant Lines: 581

💛 - Coveralls


$this->io->write("Creating temporary fake git repo in $path to apply patch", true, IOInterface::VERBOSE);

// Create a fake Git repo -- just enough to make Git think it's looking at a real repo.

Choose a reason for hiding this comment

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

👋

I think by not calling git init that it relies too much on the internal implementation of the .git directory. What if a later version requires some fourth file?

I suppose if this is documented somewhere by git it would be OK.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I think you're right. Changed this to just use git init in a14cba7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants