Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Diagnostics diff#2030

Open
acamargo wants to merge 22 commits intomasterfrom
diagnostics-diff
Open

Diagnostics diff#2030
acamargo wants to merge 22 commits intomasterfrom
diagnostics-diff

Conversation

@acamargo
Copy link
Contributor

@acamargo acamargo commented Apr 26, 2025

Fixes #2029

  • I created an issue to discuss the problem I am trying to solve or an open issue already exists.
  • I added a new entry to CHANGELOG.md
  • I updated documentation if applicable (docs folder)

"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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice if one pass --diff without a REV_RANGE, we default to origin/HEAD using :default

Copy link
Contributor Author

@acamargo acamargo Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

@acamargo acamargo Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 diagnostics has diff turned off
  • clojure-lsp diagnostics --diff has diff turned on with the revision range origin/HEAD
  • clojure-lsp diagnostics --diff --diff-rev-range origin/HEAD..HEAD has diff turned on with the revision range origin/HEAD..HEAD

Copy link
Contributor Author

@acamargo acamargo Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I got the idea of having this in server/editor

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up adding the two options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the switch to babashka.cli, the --diff option now defaults to origin/HEAD when used without a value.

@ericdallo
Copy link
Member

It looks good to me, can you update the changelog?

@acamargo acamargo marked this pull request as ready for review May 2, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diagnostics Diff

2 participants