-
Notifications
You must be signed in to change notification settings - Fork 460
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 'origin/main' does not fetch if not present #710
Comments
Interesting, good idea! I think GitHub is doing Even so, I still think it's better to print a warning like "This is silly, you should just do a full clone to start. No worries though, we'll do the fetch ourselves" and just fix it ourselves, as you suggest. The clever thing would be to do spotless/lib-extra/src/main/java/com/diffplug/spotless/extra/GitRatchet.java Lines 201 to 213 in df3ee6b
|
I spent ~ 10 min poking at the code and the JGit API. I really don't feel like I have the depth of knowledge here of how Git works to appropriately fix this issue. The reason that I opened this PR was mostly to try to support this pull request #711. I actually don't need this for my own uses of spotless. |
Fair enough :). Can you fix #711 with |
Done! Would you like to keep this issue open in case some enterprising individual comes along and wants to resolve this, or should we close it out? |
Let's keep it open, I still think it's a good idea. |
😅 Guys, facing same and i have other issues to fix. TBH ratchet from got no use if it doesn't work on CI ? bcoz usually we check lints at ci. or do we have something like baseline file options where that file can store current lint errors and only errors that's not their in the file is reported ? |
It works in CI, but it doesn't work on a bare or |
I had the same issue with my CI (Jenkins) using Bitbucket for Git. |
This sounds like an optimization that is implemented by-default into a majority of CI tools. |
I agree, but I still think it would still be nice if Spotless fixed it automatically. If the branch that Spotless needs isn't there, it can fetch it as well as anybody. |
I might be able to take a look. What is the idea here then?
|
Spotless is looking for the merge base. So it needs the history of The idea is that if any history is missing, whether of The place where code will need to be changed is described in #710 (comment) |
After some investigation it seems to me that shallow clones don't yet play nicely with jgit. From what I understand you can't just fetch from a shallow clone, you have to either: A different story is if just the current branch has been fetched, it should not be a problem to retrieve the base branch (main). I'll focus on this for now. |
Using command-line git is an option too. We use it here
If you go this route, I would use |
* Workaround until spotless fetches ratchetFrom base automatically * Details: diffplug/spotless#710
CI would fail due to spotless not doing a full checkout. More information here: diffplug/spotless#710 Fix clickEvent not being reachable. Added copyright holder.
Another question about the workaround is usually we use |
I would use environment variables and do something like: String ratchetAnchor = if (System.getenv('CI') == 'true') 'origin/main' else 'upstream/main'
spotless {
ratchetFrom ratchetAnchor |
@nedtwigg Pretty cool, thanks! |
JGit 6.3 added support for manipulating shallow clones. We would need to bump our minimum JRE to 11 to use JGit 6.3, but I'd be happy to do that if someone needs it to "fix" shallow clones to include the refs we need. |
In case anyone runs into this issue with BitBucket Pipelines, adding |
Anyone using travis can override by adding the following in the git:
depth: false |
Easy short-term fix? → Internally convert all spotless tasks to no-ops when the
|
I think you could accomplish the above with spotless {
enforceCheck env['CI'] != 'true' |
(I'm probably going off-topic for this issue, but appreciate the quick response!)
I don't think that works for us: we are running |
Currently, Spotless (Gradle Plugin) performs a check for the presence of the ratchetFrom branch on every command execution. This includes instances where Spotless-specific commands aren't called, which can lead to unnecessary checks, and adds the workaround for all cases. Could we refine the ratchetFrom functionality so that it checks for branch presence only when a Spotless command is actually invoked? I believe this adjustment could be beneficial for users who integrate Spotless into their development workflows, ensuring that the tool remains as efficient and unobtrusive as possible. Let me know if your prefer a new issue on this topic |
@helloncode happy to take a PR for this, a new issue is probably better. I will delete my comment here and your comment above at some point to keep this issue more focused. |
|
On the maven side, if you skip spotless ( |
what about Azure? |
If you specify
rachetFrom
and the branch doesn't exist locally, it should be fetched by the ratchet infrastructure.https://github.com/JLLeitschuh/spotless/runs/1200916598?check_suite_focus=true#step:5:56
EDIT: Summary of workarounds from below
fetch-depth: 0
to<action>.yml
GIT_DEPTH: 0
under thevariables:
section of.gitlab-ci.yml
clone: depth: full
git: depth: false
The text was updated successfully, but these errors were encountered: