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

Linkify sha prefixes, display 'repo:' prefix #380

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

Conversation

alekstorm
Copy link
Contributor

Apologies if the new testing logic is a bit clumsy; this was the best method I could figure out.

@@ -53,14 +53,16 @@ def disapprove
end

# Attempt to prefix-match a SHA
def self.prefix_match(git_repo, partial_sha, zero_commits_ok = false)
def self.prefix_match(git_repo, partial_sha, zero_commits_ok = false, multiple_commits_ok = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

allow_ambiguous_match I think is clearer, but in any case, this param could use a description in the method-level comment.

@philc
Copy link
Contributor

philc commented Dec 29, 2012

Very nice feature Alek. My only concern would be that it results in many more sha lookups, but for small bodies of text that shouldn't matter.

As soon as you can take care of a few of the code review comments, I'll merge this in. Looking forward to it!

str.gsub(/(^|\s)(([a-zA-Z0-9_-]+):)?([a-zA-Z0-9]{40})/m) do
repo = Regexp.last_match(3) || repo_name
sha = Regexp.last_match(4)
str.gsub(/(^|\s)(([a-zA-Z0-9_-]+):)?([a-zA-Z0-9]{7,40})/m) do |match|
Copy link
Contributor

Choose a reason for hiding this comment

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

The shas coming from git tools are always lowercase, so we could remove A-Z in that character class if we want it to match fewer things. Although the git tooling handles uppercase shas.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could do that, but it sounds like a premature optimization, especially since git handles uppercase shas.

@alekstorm
Copy link
Contributor Author

Fixed in 9bf9e89.

@alekstorm
Copy link
Contributor Author

If the sha lookups start to hurt, we can start caching pre-filtered comment text in Redis (although preferably only for older comments, since newer ones sometimes reference commits that haven't been pushed yet), or add an index on the commits.sha column.

@cespare
Copy link
Contributor

cespare commented Feb 14, 2013

Nice feature. Just got another request for this today. I'm ready to merge after we confirm my inline comment.

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.

3 participants