Skip to content

indra-git: fails to discover repository when project is not at repository root #165

Open
@cbs228

Description

@cbs228

The indra-git plugin fails to discover the containing repository if the gradle project does not reside at the repository root. This is not the case for monorepos, git-subtrees, and other repository structures that contain multiple projects.

From IndraGitService.java:115, it appears that the plugin discovers the repository like this:

final Repository repo = new RepositoryBuilder().setWorkTree(targetDir).setGitDir(realGit).setMustExist(true).build();

The upstream JGit documentation recommends using an approach like this:

new RepositoryBuilder()
                .setGitDir(gitDirArgument) // --git-dir if supplied, no-op if null
                .readEnviroment() // scan environment GIT_* variables
                .findGitDir() // scan up the file system tree
                .build()

where findGitDir() traverses up the filesystem like the git executable does.

If indra-git performed a filesystem traversal with findGitDir(), it would probably be compatible with monorepo layouts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions