Show More
@@ -33,7 +33,7 b' from tg import response' | |||||
33 | from tg import tmpl_context as c |
|
33 | from tg import tmpl_context as c | |
34 | from tg.i18n import ugettext as _ |
|
34 | from tg.i18n import ugettext as _ | |
35 |
|
35 | |||
36 | from kallithea import CONFIG |
|
36 | import kallithea | |
37 | from kallithea.lib import feeds |
|
37 | from kallithea.lib import feeds | |
38 | from kallithea.lib import helpers as h |
|
38 | from kallithea.lib import helpers as h | |
39 | from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired |
|
39 | from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired | |
@@ -67,7 +67,7 b' class FeedController(BaseRepoController)' | |||||
67 | desc_msg.append('tag: %s<br/>' % tag) |
|
67 | desc_msg.append('tag: %s<br/>' % tag) | |
68 |
|
68 | |||
69 | changes = [] |
|
69 | changes = [] | |
70 | diff_limit = safe_int(CONFIG.get('rss_cut_off_limit', 32 * 1024)) |
|
70 | diff_limit = safe_int(kallithea.CONFIG.get('rss_cut_off_limit', 32 * 1024)) | |
71 | raw_diff = cs.diff() |
|
71 | raw_diff = cs.diff() | |
72 | diff_processor = DiffProcessor(raw_diff, |
|
72 | diff_processor = DiffProcessor(raw_diff, | |
73 | diff_limit=diff_limit, |
|
73 | diff_limit=diff_limit, | |
@@ -92,7 +92,7 b' class FeedController(BaseRepoController)' | |||||
92 | desc_msg.append(h.urlify_text(cs.message)) |
|
92 | desc_msg.append(h.urlify_text(cs.message)) | |
93 | desc_msg.append('\n') |
|
93 | desc_msg.append('\n') | |
94 | desc_msg.extend(changes) |
|
94 | desc_msg.extend(changes) | |
95 | if asbool(CONFIG.get('rss_include_diff', False)): |
|
95 | if asbool(kallithea.CONFIG.get('rss_include_diff', False)): | |
96 | desc_msg.append('\n\n') |
|
96 | desc_msg.append('\n\n') | |
97 | desc_msg.append(safe_str(raw_diff)) |
|
97 | desc_msg.append(safe_str(raw_diff)) | |
98 | desc_msg.append('</pre>') |
|
98 | desc_msg.append('</pre>') | |
@@ -109,7 +109,7 b' class FeedController(BaseRepoController)' | |||||
109 | description=_('Changes on %s repository') % repo_name, |
|
109 | description=_('Changes on %s repository') % repo_name, | |
110 | ) |
|
110 | ) | |
111 |
|
111 | |||
112 | rss_items_per_page = safe_int(CONFIG.get('rss_items_per_page', 20)) |
|
112 | rss_items_per_page = safe_int(kallithea.CONFIG.get('rss_items_per_page', 20)) | |
113 | entries=[] |
|
113 | entries=[] | |
114 | for cs in reversed(list(c.db_repo_scm_instance[-rss_items_per_page:])): |
|
114 | for cs in reversed(list(c.db_repo_scm_instance[-rss_items_per_page:])): | |
115 | entries.append(dict( |
|
115 | entries.append(dict( |
@@ -38,6 +38,7 b' from tg import tmpl_context as c' | |||||
38 | from tg.i18n import ugettext as _ |
|
38 | from tg.i18n import ugettext as _ | |
39 | from webob.exc import HTTPFound, HTTPNotFound |
|
39 | from webob.exc import HTTPFound, HTTPNotFound | |
40 |
|
40 | |||
|
41 | import kallithea | |||
41 | from kallithea.config.routing import url |
|
42 | from kallithea.config.routing import url | |
42 | from kallithea.lib import diffs |
|
43 | from kallithea.lib import diffs | |
43 | from kallithea.lib import helpers as h |
|
44 | from kallithea.lib import helpers as h | |
@@ -504,13 +505,12 b' class FilesController(BaseRepoController' | |||||
504 | except (ImproperArchiveTypeError, KeyError): |
|
505 | except (ImproperArchiveTypeError, KeyError): | |
505 | return _('Unknown archive type') |
|
506 | return _('Unknown archive type') | |
506 |
|
507 | |||
507 | from kallithea import CONFIG |
|
|||
508 | rev_name = cs.raw_id[:12] |
|
508 | rev_name = cs.raw_id[:12] | |
509 | archive_name = '%s-%s%s' % (repo_name.replace('/', '_'), rev_name, ext) |
|
509 | archive_name = '%s-%s%s' % (repo_name.replace('/', '_'), rev_name, ext) | |
510 |
|
510 | |||
511 | archive_path = None |
|
511 | archive_path = None | |
512 | cached_archive_path = None |
|
512 | cached_archive_path = None | |
513 | archive_cache_dir = CONFIG.get('archive_cache_dir') |
|
513 | archive_cache_dir = kallithea.CONFIG.get('archive_cache_dir') | |
514 | if archive_cache_dir and not subrepos: # TODO: subrepo caching? |
|
514 | if archive_cache_dir and not subrepos: # TODO: subrepo caching? | |
515 | if not os.path.isdir(archive_cache_dir): |
|
515 | if not os.path.isdir(archive_cache_dir): | |
516 | os.makedirs(archive_cache_dir) |
|
516 | os.makedirs(archive_cache_dir) |
@@ -38,6 +38,7 b' from webhelpers2.html.tags import submit' | |||||
38 | from webhelpers2.number import format_byte_size |
|
38 | from webhelpers2.number import format_byte_size | |
39 | from webhelpers2.text import chop_at, truncate, wrap_paragraphs |
|
39 | from webhelpers2.text import chop_at, truncate, wrap_paragraphs | |
40 |
|
40 | |||
|
41 | import kallithea | |||
41 | from kallithea.config.routing import url |
|
42 | from kallithea.config.routing import url | |
42 | from kallithea.lib.annotate import annotate_highlight |
|
43 | from kallithea.lib.annotate import annotate_highlight | |
43 | #============================================================================== |
|
44 | #============================================================================== | |
@@ -82,9 +83,8 b' log = logging.getLogger(__name__)' | |||||
82 | def canonical_url(*args, **kargs): |
|
83 | def canonical_url(*args, **kargs): | |
83 | '''Like url(x, qualified=True), but returns url that not only is qualified |
|
84 | '''Like url(x, qualified=True), but returns url that not only is qualified | |
84 | but also canonical, as configured in canonical_url''' |
|
85 | but also canonical, as configured in canonical_url''' | |
85 | from kallithea import CONFIG |
|
|||
86 | try: |
|
86 | try: | |
87 | parts = CONFIG.get('canonical_url', '').split('://', 1) |
|
87 | parts = kallithea.CONFIG.get('canonical_url', '').split('://', 1) | |
88 | kargs['host'] = parts[1] |
|
88 | kargs['host'] = parts[1] | |
89 | kargs['protocol'] = parts[0] |
|
89 | kargs['protocol'] = parts[0] | |
90 | except IndexError: |
|
90 | except IndexError: | |
@@ -94,9 +94,8 b' def canonical_url(*args, **kargs):' | |||||
94 |
|
94 | |||
95 | def canonical_hostname(): |
|
95 | def canonical_hostname(): | |
96 | '''Return canonical hostname of system''' |
|
96 | '''Return canonical hostname of system''' | |
97 | from kallithea import CONFIG |
|
|||
98 | try: |
|
97 | try: | |
99 | parts = CONFIG.get('canonical_url', '').split('://', 1) |
|
98 | parts = kallithea.CONFIG.get('canonical_url', '').split('://', 1) | |
100 | return parts[1].split('/', 1)[0] |
|
99 | return parts[1].split('/', 1)[0] | |
101 | except IndexError: |
|
100 | except IndexError: | |
102 | parts = url('home', qualified=True).split('://', 1) |
|
101 | parts = url('home', qualified=True).split('://', 1) | |
@@ -560,9 +559,8 b' def show_id(cs):' | |||||
560 |
|
559 | |||
561 | :param cs: changeset instance |
|
560 | :param cs: changeset instance | |
562 | """ |
|
561 | """ | |
563 | from kallithea import CONFIG |
|
562 | def_len = safe_int(kallithea.CONFIG.get('show_sha_length', 12)) | |
564 | def_len = safe_int(CONFIG.get('show_sha_length', 12)) |
|
563 | show_rev = asbool(kallithea.CONFIG.get('show_revision_number', False)) | |
565 | show_rev = asbool(CONFIG.get('show_revision_number', False)) |
|
|||
566 |
|
564 | |||
567 | raw_id = cs.raw_id[:def_len] |
|
565 | raw_id = cs.raw_id[:def_len] | |
568 | if show_rev: |
|
566 | if show_rev: | |
@@ -1212,25 +1210,24 b' def urlify_issues(newtext, repo_name):' | |||||
1212 | """Urlify issue references according to .ini configuration""" |
|
1210 | """Urlify issue references according to .ini configuration""" | |
1213 | global _urlify_issues_f |
|
1211 | global _urlify_issues_f | |
1214 | if _urlify_issues_f is None: |
|
1212 | if _urlify_issues_f is None: | |
1215 | from kallithea import CONFIG |
|
|||
1216 | from kallithea.model.db import URL_SEP |
|
1213 | from kallithea.model.db import URL_SEP | |
1217 | assert CONFIG['sqlalchemy.url'] # make sure config has been loaded |
|
1214 | assert kallithea.CONFIG['sqlalchemy.url'] # make sure config has been loaded | |
1218 |
|
1215 | |||
1219 | # Build chain of urlify functions, starting with not doing any transformation |
|
1216 | # Build chain of urlify functions, starting with not doing any transformation | |
1220 | def tmp_urlify_issues_f(s): |
|
1217 | def tmp_urlify_issues_f(s): | |
1221 | return s |
|
1218 | return s | |
1222 |
|
1219 | |||
1223 | issue_pat_re = re.compile(r'issue_pat(.*)') |
|
1220 | issue_pat_re = re.compile(r'issue_pat(.*)') | |
1224 | for k in CONFIG: |
|
1221 | for k in kallithea.CONFIG: | |
1225 | # Find all issue_pat* settings that also have corresponding server_link and prefix configuration |
|
1222 | # Find all issue_pat* settings that also have corresponding server_link and prefix configuration | |
1226 | m = issue_pat_re.match(k) |
|
1223 | m = issue_pat_re.match(k) | |
1227 | if m is None: |
|
1224 | if m is None: | |
1228 | continue |
|
1225 | continue | |
1229 | suffix = m.group(1) |
|
1226 | suffix = m.group(1) | |
1230 | issue_pat = CONFIG.get(k) |
|
1227 | issue_pat = kallithea.CONFIG.get(k) | |
1231 | issue_server_link = CONFIG.get('issue_server_link%s' % suffix) |
|
1228 | issue_server_link = kallithea.CONFIG.get('issue_server_link%s' % suffix) | |
1232 | issue_sub = CONFIG.get('issue_sub%s' % suffix) |
|
1229 | issue_sub = kallithea.CONFIG.get('issue_sub%s' % suffix) | |
1233 | issue_prefix = CONFIG.get('issue_prefix%s' % suffix) |
|
1230 | issue_prefix = kallithea.CONFIG.get('issue_prefix%s' % suffix) | |
1234 | if issue_prefix: |
|
1231 | if issue_prefix: | |
1235 | log.error('found unsupported issue_prefix%s = %r - use issue_sub%s instead', suffix, issue_prefix, suffix) |
|
1232 | log.error('found unsupported issue_prefix%s = %r - use issue_sub%s instead', suffix, issue_prefix, suffix) | |
1236 | if not issue_pat: |
|
1233 | if not issue_pat: |
@@ -1,6 +1,6 b'' | |||||
1 | import mock |
|
1 | import mock | |
2 |
|
2 | |||
3 | from kallithea import CONFIG |
|
3 | import kallithea | |
4 | from kallithea.config.conf import INDEX_FILENAMES |
|
4 | from kallithea.config.conf import INDEX_FILENAMES | |
5 | from kallithea.model.meta import Session |
|
5 | from kallithea.model.meta import Session | |
6 | from kallithea.model.repo import RepoModel |
|
6 | from kallithea.model.repo import RepoModel | |
@@ -66,7 +66,7 b' def rebuild_index(full_index):' | |||||
66 | # (FYI, ENOMEM occurs at forking "git" with python 2.7.3, |
|
66 | # (FYI, ENOMEM occurs at forking "git" with python 2.7.3, | |
67 | # Linux 3.2.78-1 x86_64, 3GB memory, and no ulimit |
|
67 | # Linux 3.2.78-1 x86_64, 3GB memory, and no ulimit | |
68 | # configuration for memory) |
|
68 | # configuration for memory) | |
69 | create_test_index(base.TESTS_TMP_PATH, CONFIG, full_index=full_index) |
|
69 | create_test_index(base.TESTS_TMP_PATH, kallithea.CONFIG, full_index=full_index) | |
70 |
|
70 | |||
71 |
|
71 | |||
72 | class TestSearchControllerIndexing(base.TestController): |
|
72 | class TestSearchControllerIndexing(base.TestController): |
@@ -36,7 +36,7 b' from tempfile import _RandomNameSequence' | |||||
36 |
|
36 | |||
37 | import pytest |
|
37 | import pytest | |
38 |
|
38 | |||
39 | from kallithea import CONFIG |
|
39 | import kallithea | |
40 | from kallithea.lib.utils2 import ascii_bytes, safe_str |
|
40 | from kallithea.lib.utils2 import ascii_bytes, safe_str | |
41 | from kallithea.model.db import Repository, Ui, User, UserIpMap, UserLog |
|
41 | from kallithea.model.db import Repository, Ui, User, UserIpMap, UserLog | |
42 | from kallithea.model.meta import Session |
|
42 | from kallithea.model.meta import Session | |
@@ -101,7 +101,7 b' class HgSshVcsTest(HgVcsTest, SshVcsTest' | |||||
101 | # Specify a custom ssh command on the command line |
|
101 | # Specify a custom ssh command on the command line | |
102 | return r"""--config ui.ssh="bash -c 'SSH_ORIGINAL_COMMAND=\"\$2\" SSH_CONNECTION=\"%s 1024 127.0.0.1 22\" kallithea-cli ssh-serve -c %s %s %s' --" ssh://someuser@somehost/%s""" % ( |
|
102 | return r"""--config ui.ssh="bash -c 'SSH_ORIGINAL_COMMAND=\"\$2\" SSH_CONNECTION=\"%s 1024 127.0.0.1 22\" kallithea-cli ssh-serve -c %s %s %s' --" ssh://someuser@somehost/%s""" % ( | |
103 | client_ip, |
|
103 | client_ip, | |
104 | CONFIG['__file__'], |
|
104 | kallithea.CONFIG['__file__'], | |
105 | user.user_id, |
|
105 | user.user_id, | |
106 | ssh_key.user_ssh_key_id, |
|
106 | ssh_key.user_ssh_key_id, | |
107 | repo_name) |
|
107 | repo_name) | |
@@ -112,7 +112,7 b' class GitSshVcsTest(GitVcsTest, SshVcsTe' | |||||
112 | # Set a custom ssh command in the global environment |
|
112 | # Set a custom ssh command in the global environment | |
113 | os.environ['GIT_SSH_COMMAND'] = r"""bash -c 'SSH_ORIGINAL_COMMAND="$2" SSH_CONNECTION="%s 1024 127.0.0.1 22" kallithea-cli ssh-serve -c %s %s %s' --""" % ( |
|
113 | os.environ['GIT_SSH_COMMAND'] = r"""bash -c 'SSH_ORIGINAL_COMMAND="$2" SSH_CONNECTION="%s 1024 127.0.0.1 22" kallithea-cli ssh-serve -c %s %s %s' --""" % ( | |
114 | client_ip, |
|
114 | client_ip, | |
115 | CONFIG['__file__'], |
|
115 | kallithea.CONFIG['__file__'], | |
116 | user.user_id, |
|
116 | user.user_id, | |
117 | ssh_key.user_ssh_key_id) |
|
117 | ssh_key.user_ssh_key_id) | |
118 | return "ssh://someuser@somehost/%s""" % repo_name |
|
118 | return "ssh://someuser@somehost/%s""" % repo_name |
General Comments 0
You need to be logged in to leave comments.
Login now