#1834 Improve our markdown processor to link commits directly in the text
Merged by pingou. Opened by pingou.
commit_mk  into  master

Download 1834.patch

This way commit hash of 7 to 40 characters are automatically transformed
to link to the specified commit.

I had my cat check this regular expression out and he purred. (I don't have a cat.)

I loose hair everytime I need to touch this file

unit-tests for the win there!

Does this get() have the API where you can provide a default argument if the key is not found? If so, you could drop line 26 and all these if statements and just write something like:

user = flask.request.args.get('user', None)

If not, I just spent time typing nonsense.

You're right this can be simplified

I know this PR isn't really the space to discuss this, but it might be nice to make it so Pagure always does user/repo (similar to another popular git forge ☺) to make code like this less necessary. Of course, that would be a major backwards incompatible change.

Maybe drop this line.

What will happen here if the user types something that looks like a commit hash but doesn't actually match a real commit hash?

It was meant for easier debugging in case of problem but it can be dropped sure

I recommend adding one more that looks like a valid commit hash to the regex, but isn't a real commit in the git tree. I'd expect it to not turn into a link and still be rendered as plain text.

All comments are at your option, LGTM!

Currently it will add a link that will return a 404

We could do like issues and check if the hash exists or not before linking

So who/what was purring?

3 new commits added

  • Expand the unit-tests around our markdown processor for git commit
  • Check if the hash found exists in the repo and only link to it if it does
  • Simplify the logic around retrieving information from the request

You might be able to simplify the above block as well, and drop line 66.

Just one more comment, LGTM!

1 new commit added

  • And again some more code simplification thanks @bowlofeggs

rebased

Pull-Request has been merged by pingou

Thanks again for the review :)

Metadata