-
Notifications
You must be signed in to change notification settings - Fork 59
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
Support for git submodules #765
Comments
Are you able to perhaps make a gist with what you have as a project? Could it be that |
Sure. Here's a root project with a submodule: https://github.com/kristos80/test-root-project The submodule: https://github.com/kristos80/test-submodule in my local setup contains a .git file with that content:
If I now run |
Ah, I see what's happening :-) Indeed, This bit here is cloning your project to a temporary location, then performing a clean That does not include any kind of |
I am sorry if I don't get it correctly, but I think we are talking about something else :-)
There's no need to download any submodule, as I am not running the command from the root project but rather from within the submodule:
and not as it never reaches that code If I add this very crappy code (protect your eyes people) and run File // Instead of $sourceRepo = CheckedOutRepository::fr(Env\current_dir());
$sourceRepo = CheckedOutRepository::fromModuleFileOrPath(Env\current_dir()); File: public static function fromModuleFileOrPath(string $path): self {
if($fromModuleFile = self::fromModuleFile($path)) {
return $fromModuleFile;
}
return self::fromPath($path);
}
private static function fromModuleFile(string $path): ?self {
if(Psl\Filesystem\is_file("$path/.git")) {
$content = Psl\File\read("$path/.git");
if(str_contains($content, "gitdir:")) {
$modulePath = trim(str_replace("gitdir:", "", $content));
$path = "$path/$modulePath";
return new self($path);
}
}
return NULL;
} I hope I made myself clear! |
@kristos80 ah, I see, but that's only the first problem then, no? The problems are two, if I understand correctly:
Instead of building support for this into this particular project, I'd probably rather document the extension points to make this work, as this is really scratching the edges of what's needed.
|
@Ocramius Yes I am talking about the first problem exclusively. To be honest I cannot see how the second case could be solved, since modules are not part of the composer dependencies and can only be understood at the git level and it would require a vast amount of work as you say. Now getting back to the first problem. Yes, the problem lies in the case where the .git folder is not at the same level with the From all the info I could gather around regarding git modules here are some (probable) facts about them:
*When a project contains submodules it's called 'superproject' in git terms: https://git-scm.com/docs/gitsubmodules From the all the above if I were to add support for submodules, I would propose something like the previous code I sent:
Nevertheless my case might be a very edgy one as I need to do testing (simultaneously) on two different levels at once:
So it is very convenient to have a container to test everything at once, instead of having to test everything independently especially when all modules are in development phase as well. I would be happy to propose a PR, but I am not sure if I can compete your level :-) |
@kristos80 before going in depth in implementation, it is valuable to represent this in a test case. See https://github.com/Roave/BackwardCompatibilityCheck/tree/8.8.x/test/asset/located-sources We'd probably create a dummy project in there, with no dependencies, but so that we can point our suit at it and verify that BC breaks are caught 🤔 |
@Ocramius sounds like a plan. I'll try my best to contribute in any way I can, as well |
@kristos80 just to clear some expectations here: I'm unlikely able to implement the change myself in the next weeks. What you can do to help out is starting with the e2e test case in a PR. Worth perhaps replicating BackwardCompatibilityCheck/test/unit/LocateSources/LocateSourcesViaComposerJsonTest.php Line 27 in 92d33e4
composer.json at first?
I think we can probably expand the installation source to recurse parent directories until |
@Ocramius yes I can definitely do that in the next couple of days and if I need anything, I will ping you |
@Ocramius tests in my mac have errors and failures.:
I guess the
This is due to the fact that OSX uses the Should I include those in the PR as well? |
@kristos80 yes please, a PR with the new file structure for the tests is already awesome 👍 |
This could be hardened via |
Hi there and thanks for this wonderful project.
It seems that submodules are not supported.
I have a directory structure as such
Where the
/plugin/.git
file contains the standard module entry:gitdir: ../.git/modules/plugin
If I try to run the
vendor/bin/roave-backward-compatibility-check
command from within theplugin
directory, I get the error:Directory "/plugin" is not a GIT repository
, because as far as I can understand/plugin/.git
in my case needs to be a directory and not a file.I can see that a possible patch would be to have a statement as such
$sourceRepo = CheckedOutRepository::fromModuleFileOrPath(Env\current_dir())
inAssertBackwardsCompatible::execute
where theCheckedOutRepository
code could include something as such:I could try to create a PR but I am not sure that the proposed approach fits in your current design
The text was updated successfully, but these errors were encountered: