flex icon indicating copy to clipboard operation
flex copied to clipboard

Updating Recipe Fails When Project Located in Subfolder in Git Repository

Open Peukku opened this issue 2 years ago • 0 comments

Description

Updating Recipes is not fully applied when symfony project is located in sub-folder of the git repository.

Recipe update runs without errors, Changelog is calculated properly and some changes (file deletions and symfony.lock) are shown. Everything looks fine, unless you know that modifications are actually missing. (Like when following course video)

Repository layout:

root
-> projectB

How to reproduce

  • Create new symfony 4.4 project in subfolder of a git repo
  • Update symfony to 5.4 (replace 4.4.* with 5.4.* in composer.json and run composer update, commit changes)
  • Run composer recipes:update symfony/framework-bundle (or any recipe update that should modify files)

Result:

$ git status
On branch main
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
 	deleted:    projectB/config/bootstrap.php
	deleted:    projectB/config/packages/test/framework.yaml
	deleted:    projectB/config/routes/dev/framework.yaml
	modified:   projectB/symfony.lock

Expected Result:

$ git status
On branch main
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	modified:   projectB/.env
	deleted:    projectB/config/bootstrap.php
	modified:   projectB/config/packages/framework.yaml
	deleted:    projectB/config/packages/test/framework.yaml
	modified:   projectB/config/preload.php
	deleted:    projectB/config/routes/dev/framework.yaml
	new file:   projectB/config/routes/framework.yaml
	modified:   projectB/config/services.yaml
	modified:   projectB/public/index.php
	modified:   projectB/src/Kernel.php
	modified:   projectB/symfony.lock

Possible reason and fix

It looks like patch generation ignores the subfolder. And .git -folder location is assumed always the same. I think src-prefix and dst-prefix should be added to patch generation. And .git -folder location could be asked from git binary (git rev-parse --git-dir)

I do understand that this scenario is not very common, but outcome was very confusing with SymfonyCasts video where you can see the expected result, but locally get the other. No errors or notifications that update did not go expected.

Peukku avatar May 27 '22 21:05 Peukku