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

ratchetFrom not working in git-submodule #746

Closed
4 tasks done
conderls opened this issue Dec 7, 2020 · 4 comments
Closed
4 tasks done

ratchetFrom not working in git-submodule #746

conderls opened this issue Dec 7, 2020 · 4 comments

Comments

@conderls
Copy link

conderls commented Dec 7, 2020

If you are submitting a bug, please include the following:

  • summary of problem
    ratchetFrom not working if current project is a git-submodule. if <ratchetFrom>origin/master</ratchetFrom> section is set, nothing happended. But if the <ratchetFrom> is removed, everything works fine.
  • gradle or maven version
    maven 3.6.5
  • spotless version
    2.6.1
  • operating system and version
    Mac

there is no .git dir in git-submodule which is presented in parent module directory. Is It parsing and filter modified files using ./.git directory?

@conderls
Copy link
Author

conderls commented Dec 7, 2020

BTW, why not using 'origin/master' instead of 'origin/main' in <ratchetFrom> by default.

@nedtwigg
Copy link
Member

nedtwigg commented Dec 7, 2020

Interesting... I thought that we did support submodule, but we don't have a test for that, so not too surprised if it is broken. This is probably where the bug lives, PR's welcome.

public synchronized ObjectId rootTreeShaOf(Project project, String reference) {
try {
Repository repo = repositoryFor(project);
ObjectId treeSha = rootTreeShaCache.get(repo, reference);
if (treeSha == null) {
try (RevWalk revWalk = new RevWalk(repo)) {
ObjectId commitSha = repo.resolve(reference);
if (commitSha == null) {
throw new IllegalArgumentException("No such reference '" + reference + "'");
}
RevCommit ratchetFrom = revWalk.parseCommit(commitSha);
RevCommit head = revWalk.parseCommit(repo.resolve(Constants.HEAD));
revWalk.setRevFilter(RevFilter.MERGE_BASE);
revWalk.markStart(ratchetFrom);
revWalk.markStart(head);
RevCommit mergeBase = revWalk.next();
treeSha = Optional.ofNullable(mergeBase).orElse(ratchetFrom).getTree();
}
rootTreeShaCache.put(repo, reference, treeSha);
}
return treeSha;
} catch (IOException e) {
throw Errors.asRuntime(e);
}
}

why not using 'origin/master' instead of 'origin/main'

https://www.infoq.com/news/2020/10/github-main-branch/

conderls pushed a commit to conderls/spotless that referenced this issue Dec 23, 2020
conderls pushed a commit to conderls/spotless that referenced this issue Dec 23, 2020
conderls pushed a commit to conderls/spotless that referenced this issue Dec 23, 2020
conderls pushed a commit to conderls/spotless that referenced this issue Dec 23, 2020
conderls pushed a commit to conderls/spotless that referenced this issue Dec 23, 2020
conderls pushed a commit to conderls/spotless that referenced this issue Dec 23, 2020
conderls pushed a commit to conderls/spotless that referenced this issue Dec 24, 2020
@nedtwigg
Copy link
Member

nedtwigg commented Jan 4, 2021

Fixed in plugin-gradle 5.9.0 and plugin-maven 2.7.0, can you confirm?

@nedtwigg
Copy link
Member

nedtwigg commented Feb 9, 2021

Bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants