Skip to content

Commit

Permalink
GitWeb: Also handle urls with a dash in them
Browse files Browse the repository at this point in the history
  • Loading branch information
pieter committed Sep 25, 2008
1 parent af7925d commit bd5005a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def parse(channel, message)
when /<(?:([a-zA-Z0-9\-]+) )?([^:?\^\$\~ ]+?)(:([^:?\^\$\~ ]+))?>/
return handle_extended(channel, $1, $2, $4)
# Matches an explicit repo
when /<([a-z]+:[a-zA-Z0-9\/\?=;.]+) ([^:?\^\$\~ ]+?)(:([^:?\^\$\~ ]+))?>/
when /<([a-z]+:[a-zA-Z0-9\/\?=;.\-]+) ([^:?\^\$\~ ]+?)(:([^:?\^\$\~ ]+))?>/
return unless repo = Git::Source::Source.find_public($1)
return repo.lookup($2, $4)
when /\b([0-9a-f]{6,40})\b/
Expand Down
2 changes: 1 addition & 1 deletion lib/git/sources/gitweb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def name
end

def matches?(match)
return @url =~ /\b#{match}[a-z]*\.git/
return @url =~ /\b#{match}[a-z\-\.0-9]*\.git/
end

def object_url(ref, file)
Expand Down
5 changes: 5 additions & 0 deletions test/gitweb/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def test_external_path
@web.hook_privmsg_chan(@irc, "Look at <repo:etorrent.git HEAD>")
assert_match(/^\[etorrent HEAD\]: http.* -- .*/, @irc.message)
end

def test_external_complex
@web.hook_privmsg_chan(@irc, "<repo:linux-2.6.git 6c3a158316>")
assert_match(/^\[linux-2.6 6c3a15831\]: http.* -- .*/, @irc.message)
end

def test_unacessible_repo_nil
@web.hook_privmsg_chan(@irc, "This is local: <file://" + GIT_DIR + " HEAD>")
Expand Down

0 comments on commit bd5005a

Please sign in to comment.