1   
 2   
 3   
 4   
 5   
 6   
 7   
 8   
 9   
10   
11   
12   
13   
14   
15   
16  import re 
17   
20          if isinstance(repo_urls, str) or isinstance(repo_urls, unicode): 
21              repo_urls = [ repo_urls ] 
22          self.repo_urls = map(re.compile, repo_urls) 
23          self.revlink = revlink 
 25          for url in self.repo_urls: 
26              m = url.match(repo) 
27              if m: 
28                  return m.expand(self.revlink) % rev 
  29   
30  GithubRevlink = RevlinkMatch( 
31          repo_urls = [ r'https://github.com/([^/]*)/([^/]*?)(?:\.git)?$', 
32              r'git://github.com/([^/]*)/([^/]*?)(?:\.git)?$', 
33              r'git@github.com:([^/]*)/([^/]*?)(?:\.git)?$', 
34              r'ssh://git@github.com/([^/]*)/([^/]*?)(?:\.git)?$' 
35              ], 
36          revlink = r'https://github.com/\1/\2/commit/%s') 
37   
40          RevlinkMatch.__init__(self, repo_urls = repo_urls, revlink = revlink + r'?p=\g<repo>;a=commit;h=%s') 
  41   
42  SourceforgeGitRevlink = GitwebMatch( 
43          repo_urls = [ r'^git://([^.]*).git.sourceforge.net/gitroot/(?P<repo>.*)$', 
44              r'[^@]*@([^.]*).git.sourceforge.net:gitroot/(?P<repo>.*)$', 
45              r'ssh://(?:[^@]*@)?([^.]*).git.sourceforge.net/gitroot/(?P<repo>.*)$', 
46              ], 
47          revlink = r'http://\1.git.sourceforge.net/git/gitweb.cgi') 
48   
53          for revlink in self.revlinks: 
54              url = revlink(rev, repo) 
55              if url: 
56                  return url 
  57   
58  default_revlink_matcher = RevlinkMultiplexer(GithubRevlink, SourceforgeGitRevlink) 
59