Skip to content

Adding files to git index does not work for projects with .git in some parent dir #397

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

Closed
fabapp2 opened this issue Sep 16, 2022 · 0 comments · Fixed by #458
Closed

Adding files to git index does not work for projects with .git in some parent dir #397

fabapp2 opened this issue Sep 16, 2022 · 0 comments · Fixed by #458
Assignees
Labels
type: bug Something isn't working
Milestone

Comments

@fabapp2
Copy link
Contributor

fabapp2 commented Sep 16, 2022

Describe the bug
When sbm.gitSupportEnabled=true and
having a project which does not contain .git but one of it's parent dirs do
and a recipe is successfully applied
then the commit is empty because the modified resources were not added.

To Reproduce

Given a project setup like this:

parent-dir/.git <-- some parent of scanned dir
parent-dir/scanned-dir  <-- was scanned
  • Run a recipe that modifies resources (e.g. migrate-jpa-to-spring-boot where files are deleted and modified)
  • The resulting commit will not contain any resources and git status will be not clean as modified resources were not added to the index

Expected behavior
All resources modified by the recipe should have been added to the git index and be part of the commit.

Additional context
The problem is that the absolute paths for resources added to the index are relativized to the project's root path.
Thus the relative path is wrong, the resources are not added and the commit is empty.
The path must be calculated relative to the dir that contains the .git dir

See: GitSupport.makeRelativeToRepositoryLocation()

@fabapp2 fabapp2 added the type: bug Something isn't working label Sep 16, 2022
@fabapp2 fabapp2 self-assigned this Sep 28, 2022
@fabapp2 fabapp2 added this to the v0.13.0 milestone Sep 28, 2022
fabapp2 added a commit that referenced this issue Sep 30, 2022
@fabapp2 fabapp2 linked a pull request Sep 30, 2022 that will close this issue
fabapp2 added a commit that referenced this issue Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
1 participant