allura
修订版 | 89e2acfba56bf3474294aa7f9652c3d25d7e6775 (tree) |
---|---|
时间 | 2011-03-23 23:35:21 |
作者 | John Hoffmann <jwh@geek...> |
Commiter | Rick Copeland |
[#1570] Refactor the https instructions, making if available on every repo view for all 3 scm types.
Signed-off-by: John Hoffmann <jwh@geek.net>
@@ -233,6 +233,10 @@ class Repository(Artifact): | ||
233 | 233 | tpl = string.Template(tg.config.get('scm.host.rw.%s' % self.tool)) |
234 | 234 | return tpl.substitute(dict(username=username, path=self.url_path+self.name)) |
235 | 235 | |
236 | + def readwrite_https_path(self, username): | |
237 | + tpl = string.Template(tg.config.get('scm.host.https.%s' % self.tool)) | |
238 | + return tpl.substitute(dict(username=username, path=self.url_path+self.name)) | |
239 | + | |
236 | 240 | def merge_requests_by_statuses(self, *statuses): |
237 | 241 | return MergeRequest.query.find(dict( |
238 | 242 | app_config_id=self.app.config._id, |
@@ -20,6 +20,13 @@ | ||
20 | 20 | class="selectText" |
21 | 21 | value="{{repo.readwrite_clone_command()}}"/> |
22 | 22 | </div> |
23 | + <p>The repository is also available via HTTPS for those who are unable to use the above methods due to firewall restrictions. HTTPS is slower and requires more bandwidth than any other access method.</p> | |
24 | + <label for="rw_https" class="grid-3">Read / write</label> | |
25 | + <div class="grid-16"> | |
26 | + <input id="rw_https" style="width:40em;" readonly type="text" | |
27 | + class="selectText" | |
28 | + value="{{repo.readwrite_https_command()}}"/> | |
29 | + </div> | |
23 | 30 | <br style="clear:both;"/> |
24 | 31 | {% endif %} |
25 | 32 | {% endif %} |
@@ -69,10 +69,13 @@ static.url_base = /nf/%(build_key)s/_static_/ | ||
69 | 69 | |
70 | 70 | scm.host.ro.git = git://git.localhost$path |
71 | 71 | scm.host.rw.git = ssh://$username@localhost:8022/scm-repo$path |
72 | +scm.host.https.git = https://$username@localhost:8022/scm-repo$path | |
72 | 73 | scm.host.ro.hg = http://hg.localhost$path |
73 | 74 | scm.host.rw.hg = ssh://$username@localhost:8022/scm-repo$path |
75 | +scm.host.https.hg = https://$username@localhost:8022/scm-repo$path | |
74 | 76 | scm.host.ro.svn = http://svn.localhost$path |
75 | 77 | scm.host.rw.svn = svn+ssh://$username@localhost:8022/scm-repo$path |
78 | +scm.host.https.svn = https://$username@localhost:8022/scm-repo$path | |
76 | 79 | |
77 | 80 | gitweb.cgi = /usr/lib/cgi-bin/gitweb.cgi |
78 | 81 |
@@ -37,6 +37,10 @@ class Repository(M.Repository): | ||
37 | 37 | tpl = string.Template(tg.config.get('scm.host.rw.%s' % self.tool)) |
38 | 38 | return tpl.substitute(dict(username=username, path=self.url_path+self.name[:-4])) |
39 | 39 | |
40 | + def readwrite_https_path(self, username): | |
41 | + tpl = string.Template(tg.config.get('scm.host.https.%s' % self.tool)) | |
42 | + return tpl.substitute(dict(username=username, path=self.url_path+self.name[:-4])) | |
43 | + | |
40 | 44 | def readonly_clone_command(self): |
41 | 45 | ro_path = self.readonly_path(c.user.username) |
42 | 46 | if ro_path: |
@@ -48,6 +52,10 @@ class Repository(M.Repository): | ||
48 | 52 | rw_path = self.readwrite_path(c.user.username) |
49 | 53 | return 'git clone %s %s' % (rw_path, c.project.shortname.replace('/','.')) |
50 | 54 | |
55 | + def readwrite_https_command(self): | |
56 | + rw_https_path = self.readwrite_https_path(c.user.username) | |
57 | + return 'git clone %s %s' % (rw_https_path, c.project.shortname.replace('/','.')) | |
58 | + | |
51 | 59 | def merge_command(self, merge_request): |
52 | 60 | '''Return the command to merge a given commit to a given target branch''' |
53 | 61 | return 'git checkout %s;\ngit fetch git://%s %s;\ngit merge %s' % ( |
@@ -10,24 +10,8 @@ | ||
10 | 10 | |
11 | 11 | {% block header %}{{c.app.config.options.mount_label}}{% endblock %} |
12 | 12 | |
13 | -{% macro https_instructions(repo) %} | |
14 | - {% if repo %} | |
15 | - {% if h.has_artifact_access('write')() %} | |
16 | - <p>The repository is also available via HTTPS for those who are unable to use the SSH or git methods due to firewall restrictions. HTTP is slower and requires more bandwidth than any other access method.</p> | |
17 | - <label for="rw_https" class="grid-3">Read / write</label> | |
18 | - <div class="grid-16"> | |
19 | - <input id="rw_https" style="width:40em;" readonly type="text" | |
20 | - class="selectText" | |
21 | - value="{{repo.readwrite_clone_command().replace('ssh://','https://')}}"/> | |
22 | - </div> | |
23 | - <br style="clear:both;"/> | |
24 | - {% endif %} | |
25 | - {% endif %} | |
26 | -{% endmacro %} | |
27 | - | |
28 | 13 | {% block content %} |
29 | 14 | {{ clone_info(c.app.repo) }} |
30 | - {{ https_instructions(c.app.repo) }} | |
31 | 15 | {% if log %} |
32 | 16 | <h2>Recent Commits{% if branch %} on {{branch}}{% endif %}</h2> |
33 | 17 | {{c.log_widget.display(value=log, show_paging=False, |
@@ -45,6 +45,10 @@ class Repository(M.Repository): | ||
45 | 45 | rw_path = self.readwrite_path(c.user.username) |
46 | 46 | return 'hg clone %s %s' % (rw_path, c.project.shortname.replace('/','.')) |
47 | 47 | |
48 | + def readwrite_https_command(self): | |
49 | + rw_https_path = self.readwrite_https_path(c.user.username) | |
50 | + return 'hg clone %s %s' % (rw_https_path, c.project.shortname.replace('/','.')) | |
51 | + | |
48 | 52 | def merge_command(self, merge_request): |
49 | 53 | '''Return the command to merge a given commit into a given target branch''' |
50 | 54 | return 'hg checkout %s;\nhg pull -r %s hg://%s; hg merge %s' % ( |
@@ -45,6 +45,10 @@ class Repository(M.Repository): | ||
45 | 45 | rw_path = self.readwrite_path(c.user.username) |
46 | 46 | return 'svn checkout %s %s' % (rw_path, c.project.shortname.replace('/','.')) |
47 | 47 | |
48 | + def readwrite_https_command(self): | |
49 | + rw_https_path = self.readwrite_https_path(c.user.username) | |
50 | + return 'svn checkout %s %s' % (rw_https_path, c.project.shortname.replace('/','.')) | |
51 | + | |
48 | 52 | def _log(self, rev, skip, max_count): |
49 | 53 | ci = self.commit(rev) |
50 | 54 | if ci is None: return [] |