Package buildbot :: Module revlinks
[frames] | no frames]

Source Code for Module buildbot.revlinks

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16  import re 
17   
18 -class RevlinkMatch(object):
19 - def __init__(self, repo_urls, revlink):
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
24 - def __call__(self, rev, repo):
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
38 -class GitwebMatch(RevlinkMatch):
39 - def __init__(self, repo_urls, revlink):
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
49 -class RevlinkMultiplexer(object):
50 - def __init__(self, *revlinks):
51 self.revlinks = revlinks
52 - def __call__(self, rev, repo):
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