Skip to content

Add flag to include author information in recent commits #653

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

Conversation

PriceHiller
Copy link

This PR does the following:

  • Adds capability to show author name and email in recent commits
    • By default this is disabled, it can be enabled by setting status.recent_commits_include_author_info to true
  • Adds syntax matching for recent commit messages to color this new information
  • Adds tests to cover this new functionality and prior functionality that wasn't being tested
  • Updates the Readme to reflect the new flag

See below for how the recent commits look with the author information included:
image

Closes #652 😌

@PriceHiller PriceHiller force-pushed the feat/author-column-recent-commits branch 2 times, most recently from 4438f7b to 2667ae0 Compare July 21, 2023 04:07
@PriceHiller PriceHiller marked this pull request as draft July 21, 2023 04:07
@PriceHiller PriceHiller force-pushed the feat/author-column-recent-commits branch 13 times, most recently from 3523fad to 46255b9 Compare July 21, 2023 05:01
@PriceHiller
Copy link
Author

Ok, I'm losing sanity. This Works On My Machine™, but fails in the CI.

The recent commits section should have the number of recent commits in it, right?

Mine looks like so:
image

I'm assuming that in between those parentheses should be the number of recent commits as found by status.recent_commit_count. Should be embedded on this line over here:

output:append(string.format("%s (%d)", header, #data.items))

The only reason the "Recent commits" message would have more than 10 is if this line

local result = M.list({ "--max-count=" .. tostring(count) }, false)
--max-count flag is somehow receiving a different number than config.values.status.recent_commit_count.

I'm not sure how this is happening, but it's driving me up a wall. Any idea @CKolkey @ten3roberts?

@PriceHiller PriceHiller force-pushed the feat/author-column-recent-commits branch from 46255b9 to adb1219 Compare July 21, 2023 05:05
@PriceHiller PriceHiller force-pushed the feat/author-column-recent-commits branch from adb1219 to 1dfb1a3 Compare July 21, 2023 05:37
@CKolkey
Copy link
Member

CKolkey commented Jul 21, 2023

What would be REALLY cool is to work towards how magit handles this:
Screenshot 2023-07-21 at 07 58 02

(If you don't have emacs installed, I recommend grabbing DOOM emacs to use as a reference.)

^^ Thats the Log Margin popup https://magit.vc/manual/magit/Log-Margin.html

L opens this popup. And, if you want, you can implement the functions of that popup incrementally. The two at the bottom right (s, w) don't really mean anything to neogit since we don't set defaults for stuff across projects yet, at least independant of how a user scopes state.

Using "toggle details" can turn on showing the author name:
Screenshot 2023-07-21 at 07 50 26

I think it would be super cool to implement this as the config mechanism instead of have it be hard-coded config values. You can use the state module to write/read persistent values. And an easy way to do perfect right-aligned text is with virtual text - thats how I did in the reflog view.

It also seems like magit shows the recent commits across all branches, which would be really cool to copy. Then we can show the remote/branch for the commit too.. That doesn't need to be part of this change, just had never noticed that before.

@CKolkey
Copy link
Member

CKolkey commented Jul 21, 2023

Ok, I'm losing sanity. This Works On My Machine™, but fails in the CI.

The recent commits section should have the number of recent commits in it, right?

Mine looks like so: image

I'm assuming that in between those parentheses should be the number of recent commits as found by status.recent_commit_count. Should be embedded on this line over here:

output:append(string.format("%s (%d)", header, #data.items))

The only reason the "Recent commits" message would have more than 10 is if this line

local result = M.list({ "--max-count=" .. tostring(count) }, false)

--max-count flag is somehow receiving a different number than config.values.status.recent_commit_count.
I'm not sure how this is happening, but it's driving me up a wall. Any idea @CKolkey @ten3roberts?

Hmm. That seems right to me. Whats the actual number being shown in CI?

@PriceHiller
Copy link
Author

Ok, I'm losing sanity. This Works On My Machine™, but fails in the CI.
The recent commits section should have the number of recent commits in it, right?
Mine looks like so: image
I'm assuming that in between those parentheses should be the number of recent commits as found by status.recent_commit_count. Should be embedded on this line over here:

output:append(string.format("%s (%d)", header, #data.items))

The only reason the "Recent commits" message would have more than 10 is if this line

local result = M.list({ "--max-count=" .. tostring(count) }, false)

--max-count flag is somehow receiving a different number than config.values.status.recent_commit_count.
I'm not sure how this is happening, but it's driving me up a wall. Any idea @CKolkey @ten3roberts?

Hmm. That seems right to me. Whats the actual number being shown in CI?

CI is getting 51 back instead of 10 for that.

@PriceHiller
Copy link
Author

What would be REALLY cool is to work towards how magit handles this: Screenshot 2023-07-21 at 07 58 02

(If you don't have emacs installed, I recommend grabbing DOOM emacs to use as a reference.)

^^ Thats the Log Margin popup https://magit.vc/manual/magit/Log-Margin.html

L opens this popup.

Using "toggle details" can turn on showing the author name: Screenshot 2023-07-21 at 07 50 26

I think it would be super cool to implement this as the config mechanism instead of have it be hard-coded config values. You can use the state module to write/read persistent values. And an easy way to do perfect right-aligned text is with virtual text - thats how I did in the reflog view.

It also seems like magit shows the recent commits across all branches, which would be really cool to copy. Then we can show the remote/branch for the commit too.. That doesn't need to be part of this change, just had never noticed that before.

That's neat, I used emacs for a while, but stuck to CLI git. My exposure to Magit is entirely via Neogit.

I'll see what it'll take to replicate that.

@CKolkey
Copy link
Member

CKolkey commented Jul 21, 2023

That's neat, I used emacs for a while, but stuck to CLI git. My exposure to Magit is entirely via Neogit.

I'll see what it'll take to replicate that.

Haha, no kidding. My only exposure to emacs is for referencing stuff to implement in Neogit.

It should be pretty simple to add the popup. You'll need:

popups/log_margin/init.lua
popups/log_margin/actions.lua

Just copy the pattern used by all the other popups. actions exports each function of the popup as a function. For testing, only the branch popup's actions are properly wrapped by the operations module. Thats a decent reference.

Otherwise, as you'll see, each action takes the popup as it's first/only argument, and the popup object has popup:get_arguments()
to see which config/options are enabled. Other than that, it should be pretty simple. @ten3roberts just updated the popups api so you should need to add fewer references to get this referenced in multiple places.

The init.lua just uses a builder to add all the config/options/flags/actions. -n is an option, -o is a config, and -g, -c, -d are switches. Don't worry about adding all of them now.

@PriceHiller
Copy link
Author

Cool!

I guess I'll make this my next goal with Neogit -- nice stuff for the recent commits buffer.

This is gonna take a minute... well into the breach I go.

@PriceHiller
Copy link
Author

Closing this in favor of a full fledged popup PR.

@CKolkey
Copy link
Member

CKolkey commented Jul 21, 2023

It's a breaking change, but changing the log popup to l and taking L for this is fine. I'd like to align with magit as much as is reasonable.

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.

Add Author Column to Recent Commits
2 participants