Conversation
cli/src/clojure_lsp/main.clj
Outdated
| "Invalid --analysis EDN"] | ||
| :assoc-fn #(assoc %1 %2 (edn/read-string %3))]]) | ||
| :assoc-fn #(assoc %1 %2 (edn/read-string %3))] | ||
| ["-d" "--diff REV_RANGE" "Diagnose only the changes between the two revisions. REV_RANGE is a git revision range, e.g. origin/HEAD..HEAD or origin/HEAD" |
There was a problem hiding this comment.
would be nice if one pass --diff without a REV_RANGE, we default to origin/HEAD using :default
There was a problem hiding this comment.
Totally agree, but unfortunately parse-opts doesn't support optional argument to options. :-/
If we declare a :default, this options will be always returned and we have no way to know if it was provided or not.
(parse-opts [] [["-d" "--diff REV_RANGE" "Diagnose only the changes between the two revisions. REV_RANGE is a git revision range, e.g. origin/HEAD..HEAD or origin/HEAD"
:id :diff
:default "origin/HEAD..HEAD"
:validate [#(re-matches #"^[\w navigating around the git history \-./~^@{}]+(?:(?:\.\.|\.\.\.)[\w navigating around the git history \-./~^@{}]+)?$" %) "Invalid git revision range"]]])
=>
{:options {:diff "origin/HEAD..HEAD"}, :arguments [], :summary " -d, --diff REV_RANGE origin/HEAD..HEAD Diagnose only the changes between the two revisions. REV_RANGE is a git revision range, e.g. origin/HEAD..HEAD or origin/HEAD", :errors nil}
As you can see, when the option has :default and args is [] then parse-opts result contains the :diff key.
There was a problem hiding this comment.
yeah, what a boomer, what about we have a special sym that we replace later in the :default, like --diff <HEAD>, and we specifically make a replace of <HEAD> to origin/HEAD? I dunno, do you think it's too bad?
There was a problem hiding this comment.
Something we can do is to have a separate option for the revision (diff-rev-range defaulting to origin/HEAD) and another one to turn on the diff.
Like
clojure-lsp diagnosticshas diff turned offclojure-lsp diagnostics --diffhas diff turned on with the revision rangeorigin/HEADclojure-lsp diagnostics --diff --diff-rev-range origin/HEAD..HEADhas diff turned on with the revision rangeorigin/HEAD..HEAD
There was a problem hiding this comment.
Food for thought: What if we provided this functionality on the server/editor? This could give us something similar to that "snapshot" idea. This could be the next step and I'm OK not increasing the scope of this PR.
There was a problem hiding this comment.
not sure I got the idea of having this in server/editor
There was a problem hiding this comment.
brought this issue to https://clojurians.slack.com/archives/C03S1KBA2/p1745859358672599
There was a problem hiding this comment.
I ended up adding the two options.
There was a problem hiding this comment.
With the switch to babashka.cli, the --diff option now defaults to origin/HEAD when used without a value.
|
It looks good to me, can you update the changelog? |
Fixes #2029
docsfolder)