Githawk: Shorten and linkify commit hashes

Created on 19 Oct 2018  Â·  9Comments  Â·  Source: GitHawkApp/GitHawk

Example comment: https://github.com/MichaelMure/git-bug/issues/69#issuecomment-430811694

On GitHub.com, the hash in the comment is converted to code, truncated to a smaller length, and linked to the actual commit.

Can GitHawk do this too?


Bug Report Dump (Auto-generated)

Version 1.23.0 (1539742783)
Device: iPhone 8 (iOS 12.0.1)
TestFlight: true

âť” question

All 9 comments

Is there a regex rule for commit hashes?

Sent with GitHawk

Yes, but unfortunately it’s [\da-f]{7,40}. You’d then have to check matching strings to see if they correspond to a real commit (on the plus side, if a commit is found, the SHA can be cached indefinitely). As a start, truncating and linkifying the 40-character ones would make them a lot easier to read.

Yikes that’s match tons of normal words. Sadly don’t think this will be possible without the API marking commit hashes.

Sent with GitHawk

Aha: GitHub has an API for rendering Markdown.

There’s also a way to get GitHub to send you the HTML for a given comment.

Unfortunately we’ve put a LOT of time and effort into making our markdown hella fast. Way faster than we’d get with Web views.

Sent with GitHawk

Could you use NSAttributedString to convert the HTML to a native string?

That uses a WebKit underneath and has to be done on the main thread.

Sent with GitHawk

At least the truncated display (first 7 digits) would help to view posts where commits are referenced...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rnystrom picture rnystrom  Â·  3Comments

BasThomas picture BasThomas  Â·  3Comments

rnystrom picture rnystrom  Â·  3Comments

BasThomas picture BasThomas  Â·  3Comments

BasThomas picture BasThomas  Â·  3Comments