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

Blame command returns null result for gradle module #119

Open
unkali opened this issue Dec 10, 2024 · 1 comment
Open

Blame command returns null result for gradle module #119

unkali opened this issue Dec 10, 2024 · 1 comment
Labels
need info Waiting for more information

Comments

@unkali
Copy link

unkali commented Dec 10, 2024

Version

All versions after 5.5.1

Operating System

MacOS

Bug description

I have a gradle project with the following repository structure (Java version : 17)

my-api
    .github/
    .idea/
    gradle/
    .gitignore
    settings.gradle
    my-api
        build.gradle
        src
            main
                java
                    com.example
                        Application.java

The blame command works for files which are direct children of my-api except for any files under my-api/my-api module.
Please see the following code that I am using to check this behaviour

public class Jgit {

    static final String REPO = "/Users/kapil-mangtani/IdeaProjects/my-api/.git";
    static final String PATH1 = "settings.gradle";
    static final String PATH2 = ".github/workflows/build-deploy-dev.yml";
    static final String PATH3 = "my-api/src/main/java/com/example/Application.java";

    public static void main(String[] args) throws Exception {
        FileRepositoryBuilder builder = new FileRepositoryBuilder();
        Git git = new Git(builder.setGitDir(new File(REPO)).readEnvironment().findGitDir().build());

        BlameCommand blameCommand = git.blame().setFilePath(PATH1);
        BlameResult result = blameCommand.call();
        assert result != null;   // TRUE

        BlameCommand blameCommand1 = git.blame().setFilePath(PATH2);
        BlameResult result1 = blameCommand1.call();
        assert result1 != null;  // TRUE

        BlameCommand blameCommand2 = git.blame().setFilePath(PATH3);
        BlameResult result2 = blameCommand2.call();
        assert result2 != null;  // FALSE for versions above 5.5.1
}

In my build.gradle file, I have
implementation 'org.eclipse.jgit:org.eclipse.jgit:<version>'

Now when the version is 5.5.1 or below, result2 is not null and contains the blame result, but any version after that eg. 5.13.3, or 6.2.0 or even the latest one 7.1.0 returns the result2 as null. I have verified the same behaviour using the standalone sh file as well for the same versions using the blame -w command

Actual behavior

blame result is null as seen in the code snippet above

Expected behavior

blame result to be non-null with author and commit information (as seen in versions 5.5.1 and prior)

Relevant log output

No response

Other information

No response

@unkali unkali changed the title Blame command returns null for gradle module Blame command returns null result for gradle module Dec 10, 2024
@tomaswolf
Copy link
Contributor

Please provide a Github public repo with which one can reproduce this.

@tomaswolf tomaswolf added the need info Waiting for more information label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need info Waiting for more information
Projects
None yet
Development

No branches or pull requests

2 participants