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

status.lua: Display commit and branch of repository where file is located #3673

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

niten94
Copy link
Contributor

@niten94 niten94 commented Feb 23, 2025

The repository where the file is located could be different with the current directory, so the functions in the status plugin are changed to run commands in the directory of the file.

Return current commit hash and branch of repository where file in buffer
is located instead of current directory. Update version to 1.1.0.
@@ -32,30 +35,23 @@ function size(b)
return humanize.Bytes(b:Size())
end

function branch(b)
local function parseRevision(b, opt)
if b.Type.Kind ~= buffer.BTInfo then
Copy link
Collaborator

Choose a reason for hiding this comment

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

One Addition:
In case we now compare against buffer.BTInfo shouldn't we use b.Type instead of b.Type.Kind?
Because the b.Type.Kind holds the int, but the b.Type the BufType.

Copy link
Contributor Author

@niten94 niten94 Feb 27, 2025

Choose a reason for hiding this comment

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

BufType.Kind is exposed to plugins with the same name as BufType constants, so b.Type.Kind has to be compared:

micro/cmd/micro/initlua.go

Lines 129 to 134 in 272a308

ulua.L.SetField(pkg, "BTDefault", luar.New(ulua.L, buffer.BTDefault.Kind))
ulua.L.SetField(pkg, "BTHelp", luar.New(ulua.L, buffer.BTHelp.Kind))
ulua.L.SetField(pkg, "BTLog", luar.New(ulua.L, buffer.BTLog.Kind))
ulua.L.SetField(pkg, "BTScratch", luar.New(ulua.L, buffer.BTScratch.Kind))
ulua.L.SetField(pkg, "BTRaw", luar.New(ulua.L, buffer.BTRaw.Kind))
ulua.L.SetField(pkg, "BTInfo", luar.New(ulua.L, buffer.BTInfo.Kind))

I do not know if the exposed values could somehow be changed without breaking API. Other exposed constant types are int but I was confused when I tried to compare with b.Type a year ago. Thinking about it now, I think a note could be added in documentation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I see. Thank you for this hint. 👍
Not really intuitive, but yes...right now fix in this API.

VERSION = "1.0.0"
VERSION = "1.1.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The version of builtin plugins does not seem to be updated and there is only a fix done in this pull request, so I don't know if this would be fine. I'll revert this sometime around this week.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This version as such doesn't make a lot of sense for builtin plugins (they are not released separately from micro, not downloaded or installed separately from micro). So yes, I think it's better to keep this 1.0.0, just for consistency.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What about VERSION = "builtin", which results in this particular case in status (0.0.0-builtin)?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably better to leave it as-is unless it is causing problems. It is sort of user-facing so changes could potentially break something (https://xkcd.com/1172/).

Copy link
Collaborator

Choose a reason for hiding this comment

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

By taking https://xkcd.com/1172/ serious we would end up in no change at all. 😉
The user is still able to override builtin plugins with local ones. Don't you think it would be nice to identify this use case?

Copy link
Contributor

Choose a reason for hiding this comment

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

The user is still able to override builtin plugins with local ones. Don't you think it would be nice to identify this use case?

I'm not sure how the version number is related, surely you can do that regardless of the version number? 🤔 Or do you just mean that the text "builtin" would then not be visible in the output of micro -plugin list (assuming the user remembered to change the version number in their override)? I don't really think that matters much.

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.

4 participants