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

Allow multiple hyperlinks per line #1909

Merged
merged 2 commits into from
Nov 20, 2024
Merged

Conversation

th1000s
Copy link
Collaborator

@th1000s th1000s commented Nov 14, 2024

  • Allow multiple hyperlinks per line

Previously only the last commit was linked

Do not link numbers (technically also commits), and stop after
finding 12 commits on a line.

Fixes #1907


  • testability: add pretty_assertions, git mocks

I'd want to enhance all the current assertions with pretty_assertions, that is no work compared to using insta.

Comment on lines 53 to 54
let formatted_commit =
format_osc8_hyperlink(&commit_link_format.replace("{commit}", commit), commit);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What about filtering out pure numbers here again, as mentioned in the issue?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, why not. The posterior probability of such a string being a number is going to be considerably higher than that of it being a commit. Multiplied by the probability that someone happened to care about the link to their improbably-digit-rich commit...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

commit = commit,
osc = "\x1b]",
st = "\x1b\\"
);
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a reason that we can't use format_osc8_hyperlink here also? And beyond that, The two branches of this function are quite substantial and look very similar -- did you decide it wasn't attractive to unite them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, just didn't want think about how to nicely factor that out :) - What about this HyperlinkCommits helper now?

Copy link
Owner

Choose a reason for hiding this comment

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

Nice, the helper LGTM.

Copy link
Owner

@dandavison dandavison left a comment

Choose a reason for hiding this comment

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

Great! Made a couple of comments but feel free to merge when you're happy with it.

Comment on lines 86 to 91
format!(
"{osc}8;;{url}{st}{commit}{osc}8;;{st}",
url = repo.format_commit_url(commit),
commit = commit,
osc = "\x1b]",
st = "\x1b\\"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can be replaced with format_osc8_hyperlink(), right?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes I believe so. I'm not sure why the previous code wasn't already using that. Hopefully just a historical accident rather than a Chesterton's fence.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done (tests agree)!

Previously only the last commit was linked.

Do not link numbers (technically also commits), and stop after
finding 12 commits on a line.
@th1000s th1000s merged commit 9594713 into dandavison:main Nov 20, 2024
13 checks passed
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.

🚀 Allow multiple hyperlinks per line
2 participants