13 |
from cookielib import LWPCookieJar |
from cookielib import LWPCookieJar |
14 |
from bugz.bugzilla import BugzillaProxy |
from bugz.bugzilla import BugzillaProxy |
15 |
|
|
16 |
|
import urllib2 |
17 |
|
|
18 |
# When editing this list, remember to edit the same list in |
# When editing this list, remember to edit the same list in |
19 |
# modules/cgit/templates/filter.commit-links.sh |
# modules/cgit/templates/filter.commit-links.sh |
20 |
BUG_REFS = { |
BUG_REFS = { |
41 |
""" |
""" |
42 |
git_multimail.REVISION_FOOTER_TEMPLATE = git_multimail.FOOTER_TEMPLATE |
git_multimail.REVISION_FOOTER_TEMPLATE = git_multimail.FOOTER_TEMPLATE |
43 |
|
|
44 |
|
REPO_NAME_RE = re.compile(r'^/git/(?P<name>.+?)(?:\.git)?$') |
45 |
|
def repo_shortname(): |
46 |
|
basename = os.path.abspath(git_multimail.get_git_dir()) |
47 |
|
m = REPO_NAME_RE.match(basename) |
48 |
|
if m: |
49 |
|
return m.group('name') |
50 |
|
else: |
51 |
|
return basename |
52 |
|
|
53 |
|
|
54 |
# Override the Environment class to generate an apporpriate short name which is |
# Override the Environment class to generate an apporpriate short name which is |
55 |
# used in git links and as an email prefix |
# used in git links and as an email prefix |
56 |
class LinksEnvironment(git_multimail.Environment): |
class LinksEnvironment(git_multimail.Environment): |
|
REPO_NAME_RE = re.compile(r'^/git/(?P<name>.+?)(?:\.git)?$') |
|
|
|
|
57 |
def get_repo_shortname(self): |
def get_repo_shortname(self): |
58 |
"""Use the last part of the repo path, with ".git" stripped off if present.""" |
return repo_shortname() |
|
|
|
|
basename = os.path.abspath(self.get_repo_path()) |
|
|
m = self.REPO_NAME_RE.match(basename) |
|
|
if m: |
|
|
return m.group('name') |
|
|
else: |
|
|
return basename |
|
|
|
|
59 |
git_multimail.Environment = LinksEnvironment |
git_multimail.Environment = LinksEnvironment |
60 |
|
|
61 |
# Override the Reviesion class to inject gitweb/cgit links and any referenced |
# Override the Reviesion class to inject gitweb/cgit links and any referenced |
184 |
except Exception: |
except Exception: |
185 |
pass |
pass |
186 |
|
|
187 |
|
try: |
188 |
|
req = urllib2.Request('http://alamut.mageia.org:8000', repo_shortname()) |
189 |
|
req.add_header('Content-Type', 'x-git/repo') |
190 |
|
fp = urllib2.urlopen(req) |
191 |
|
if (fp) |
192 |
|
fp.close() |
193 |
|
except Exception: |
194 |
|
pass |
195 |
|
|
196 |
git_multimail.main(sys.argv[1:]) |
git_multimail.main(sys.argv[1:]) |