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

Improved exotic paths #644

Merged
merged 33 commits into from
Sep 9, 2019
Merged

Improved exotic paths #644

merged 33 commits into from
Sep 9, 2019

Conversation

veewee
Copy link
Contributor

@veewee veewee commented May 31, 2019

Q A
Branch master
Bug fix? yes
New feature? yes
BC breaks? yes
Deprecations? no
Documented? no
Fixed tickets #643

This PR aims to fix some well known issues with exotic paths.
Previous PR (#643) introduced an issue when using conventions.
This PR will also try to fix issues when composer, git and grumphp config files are in separate directories.

This PR:

  • Gets rid of bin_dir : it is loaded from composer config instead.
  • Gets rid of git_dir: it tries to locate the git dir on every run.
  • Introduces new environment variables to change paths
  • Rewrites the paths, application, commands, container and autoloading section
  • Contains a lot of testcases on various project structures
  • Contains a system that tries to guess where all your config files (git, composer, bin, grumphp, ...) are located.
  • Fixes some long lasting filesystem issues (symlinks, submodules, relative / absolute path issues, ...)
  • Fixes issues with locating diffed / registered git files in a project dir.
  • Makes it possible to generate phars
  • Works globally installed
  • It will fix most of the open issues related to windows and the path system
  • Makes it possible to reuse same git hook in both local + vagrant scenarios

Manually tested: vagrant, vagrant preset, composer-bin-plugin, docker

You can test it as well:

composer remove phpro/grumphp
composer config repositories.grumphp-shim vcs https://github.com/veewee/grumphp
composer require --dev phpro/grumphp:dev-improved-paths

Note:
bin_dir and git_dir are removed from config. But it doesn't matter if it's still in there

$this->gitDirLocator = $gitDirLocator;
}

public function locate(?string $cliConfigFile): GuessedPaths
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Landerstraeten : moved all path guessing logic to this locator.
Can you go through it to see if it makes sense to you?

This one is constructed early in the cli boot code and will be used to tell GrumPHP where to look for stuff. (git, bins, configs, ...)

This was referenced Aug 22, 2019
This was referenced Sep 4, 2019
Copy link
Member

@janvernieuwe janvernieuwe left a comment

Choose a reason for hiding this comment

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

Only checked it high level, but it looked alright to me.
Just a few minor questions.

doc/installation/exotic.md Show resolved Hide resolved
@@ -3,9 +3,15 @@ services:
class: GrumPHP\Event\Subscriber\StashUnstagedChangesSubscriber
arguments:
- '@config'
- '@git.repository'
- '@GrumPHP\Git\GitRepository'
- '@grumphp.io'
Copy link
Member

Choose a reason for hiding this comment

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

Any plans to use fqcn's as service names everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently no plans for that. it's something that is happening gradually while we are improving stuff.
We could create a PR to fix them all, but it might break extensions.

);
}

return trim($process->getOutput());
Copy link
Member

Choose a reason for hiding this comment

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

this is always correct? even when multiple executables exist (weird situation i know)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be. We were using it previously as well and I don't know of a case where it doesnt do what it promises.

(Actually: when you run this in a php script in a subdir of the git root during pre-commit, it crashes. This is a git bug which is very vague, so I fixed it by adding the GRUMPHP_GIT_WORKING_DIR in the local git commit.)

@veewee veewee merged commit 9c104bb into phpro:master Sep 9, 2019
private $repositoryOptions;

/**
* @var ?Repository
Copy link
Contributor

Choose a reason for hiding this comment

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

@veewee, what's the best way to typehit: null|Repository or ?Repository?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

null|Repository works best in most IDEs I guess ...

Copy link
Contributor

@Landerstraeten Landerstraeten left a comment

Choose a reason for hiding this comment

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

Very, very nice @veewee!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC BREAK enhancement Paths Issues related to paths
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants