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

mono -> many repo structure feasibility #531

Closed
redthor opened this issue Aug 16, 2018 · 1 comment
Closed

mono -> many repo structure feasibility #531

redthor opened this issue Aug 16, 2018 · 1 comment

Comments

@redthor
Copy link

redthor commented Aug 16, 2018

Q A
Version 0.14.1
Bug? yes
New feature? yes
Question? yes
Documentation? no
Related tickets

Thanks for GrumPHP!

I'm setting up for the first time and I just wanted to get some feedback on GrumPHP and applicability with the mono -> many repo structure enabled by https://github.com/splitsh/lite and https://github.com/jderusse/docker-gitsplit

It simply might not be suitable, but you might have some feedback or ideas for me, hence this ticket.

Given this structure:

/mono
  /.git
  /projectA (commits in the folder are sent to git@business.com:business/projectA.git by a CI job)
    /src
    /tests
    /composer.json
    /grumphp.yml
  /projectB
  /..

I added "phpro/grumphp" into projectA/composer.json and GrumPHP created projectA/.git and added the hooks in there instead of adding it to mono/.git/. The fix might be to look recursively up the folder tree for .git/ and and use that one instead. However I then realised there were other problems with my setup.

You can set GrumPHP config to look at the right .git/ folder:

# projectA/grumphp.yml
parameters:
    # assuming we are working from the mono repo
    git_dir: ../.git

Then run GrumPHP from the projectA folder:

cd mono\projectA
./vendor/bin/grumphp run

The issue is that it appears to prefix CWD to the files it finds with ls-files. Also, ls-files is returning all files from all project folders. It then passes to the Task, e.g. phpmd, which then complains the files cannot be found:

# projectA files:
Path /mono/projectA/projectA/src/Business/ProjectA/MyClass.php does not exist

# projectB files:
Path /mono/projectA/projectB/src/Business/ProjectB/MyClass.php does not exist

I could look into a solution for this, but I did wonder, what should I expect my commit includes changes in projectB? I wasn't sure of the answer given it might have it's own projectB/grumphp.yml... One could have a warning "only checking files descending from grumphp.yml"

So to summarise:

  1. Possible ascend up and look for .git folder on initialisation;
  2. Prevent CWD prefix issue;
  3. Possible feature (config setting?) to whitelist files that descend from grumphp.yml;
@redthor
Copy link
Author

redthor commented Aug 22, 2018

Part of my issues appears to be due to git_dir parameter being the folder where the .git folder is found as opposed to the actual .git folder. Removing .git helped a bit.

In the future it'd be good if git_dir meant the "git directory" :)

@redthor redthor closed this as completed Aug 22, 2018
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

No branches or pull requests

1 participant