Show More
@@ -110,7 +110,7 b' def repo_purge_deleted(ask, older_than):' | |||||
110 | return |
|
110 | return | |
111 | parts = parts.groupdict() |
|
111 | parts = parts.groupdict() | |
112 | time_params = {} |
|
112 | time_params = {} | |
113 |
for |
|
113 | for name, param in parts.items(): | |
114 | if param: |
|
114 | if param: | |
115 | time_params[name] = int(param) |
|
115 | time_params[name] = int(param) | |
116 | return datetime.timedelta(**time_params) |
|
116 | return datetime.timedelta(**time_params) |
@@ -68,7 +68,7 b' class DefaultsController(BaseController)' | |||||
68 |
|
68 | |||
69 | try: |
|
69 | try: | |
70 | form_result = _form.to_python(dict(request.POST)) |
|
70 | form_result = _form.to_python(dict(request.POST)) | |
71 |
for k, v in form_result. |
|
71 | for k, v in form_result.items(): | |
72 | setting = Setting.create_or_update(k, v) |
|
72 | setting = Setting.create_or_update(k, v) | |
73 | Session().commit() |
|
73 | Session().commit() | |
74 | h.flash(_('Default settings updated successfully'), |
|
74 | h.flash(_('Default settings updated successfully'), |
@@ -423,7 +423,7 b' class SettingsController(BaseController)' | |||||
423 | import kallithea |
|
423 | import kallithea | |
424 | c.ini = kallithea.CONFIG |
|
424 | c.ini = kallithea.CONFIG | |
425 | server_info = Setting.get_server_info() |
|
425 | server_info = Setting.get_server_info() | |
426 |
for key, val in server_info. |
|
426 | for key, val in server_info.items(): | |
427 | setattr(c, key, val) |
|
427 | setattr(c, key, val) | |
428 |
|
428 | |||
429 | return htmlfill.render( |
|
429 | return htmlfill.render( |
@@ -180,7 +180,7 b' class JSONRPCController(TGController):' | |||||
180 | USER_SESSION_ATTR = 'apiuser' |
|
180 | USER_SESSION_ATTR = 'apiuser' | |
181 |
|
181 | |||
182 | # get our arglist and check if we provided them as args |
|
182 | # get our arglist and check if we provided them as args | |
183 |
for arg, default in func_kwargs. |
|
183 | for arg, default in func_kwargs.items(): | |
184 | if arg == USER_SESSION_ATTR: |
|
184 | if arg == USER_SESSION_ATTR: | |
185 | # USER_SESSION_ATTR is something translated from API key and |
|
185 | # USER_SESSION_ATTR is something translated from API key and | |
186 | # this is checked before so we don't need validate it |
|
186 | # this is checked before so we don't need validate it |
@@ -109,7 +109,7 b' class PullrequestsController(BaseRepoCon' | |||||
109 | tipbranch = None |
|
109 | tipbranch = None | |
110 |
|
110 | |||
111 | branches = [] |
|
111 | branches = [] | |
112 |
for abranch, branchrev in repo.branches. |
|
112 | for abranch, branchrev in repo.branches.items(): | |
113 | n = 'branch:%s:%s' % (abranch, branchrev) |
|
113 | n = 'branch:%s:%s' % (abranch, branchrev) | |
114 | desc = abranch |
|
114 | desc = abranch | |
115 | if branchrev == tiprev: |
|
115 | if branchrev == tiprev: | |
@@ -133,14 +133,14 b' class PullrequestsController(BaseRepoCon' | |||||
133 | log.debug('branch %r not found in %s', branch, repo) |
|
133 | log.debug('branch %r not found in %s', branch, repo) | |
134 |
|
134 | |||
135 | bookmarks = [] |
|
135 | bookmarks = [] | |
136 |
for bookmark, bookmarkrev in repo.bookmarks. |
|
136 | for bookmark, bookmarkrev in repo.bookmarks.items(): | |
137 | n = 'book:%s:%s' % (bookmark, bookmarkrev) |
|
137 | n = 'book:%s:%s' % (bookmark, bookmarkrev) | |
138 | bookmarks.append((n, bookmark)) |
|
138 | bookmarks.append((n, bookmark)) | |
139 | if rev == bookmarkrev: |
|
139 | if rev == bookmarkrev: | |
140 | selected = n |
|
140 | selected = n | |
141 |
|
141 | |||
142 | tags = [] |
|
142 | tags = [] | |
143 |
for tag, tagrev in repo.tags. |
|
143 | for tag, tagrev in repo.tags.items(): | |
144 | if tag == 'tip': |
|
144 | if tag == 'tip': | |
145 | continue |
|
145 | continue | |
146 | n = 'tag:%s:%s' % (tag, tagrev) |
|
146 | n = 'tag:%s:%s' % (tag, tagrev) |
@@ -442,7 +442,7 b' class AuthUser(object):' | |||||
442 | self.is_default_user = False |
|
442 | self.is_default_user = False | |
443 | else: |
|
443 | else: | |
444 | # copy non-confidential database fields from a `db.User` to this `AuthUser`. |
|
444 | # copy non-confidential database fields from a `db.User` to this `AuthUser`. | |
445 |
for k, v in dbuser.get_dict(). |
|
445 | for k, v in dbuser.get_dict().items(): | |
446 | assert k not in ['api_keys', 'permissions'] |
|
446 | assert k not in ['api_keys', 'permissions'] | |
447 | setattr(self, k, v) |
|
447 | setattr(self, k, v) | |
448 | self.is_default_user = dbuser.is_default_user |
|
448 | self.is_default_user = dbuser.is_default_user | |
@@ -525,7 +525,7 b' class AuthUser(object):' | |||||
525 | """ |
|
525 | """ | |
526 | Returns list of repositories you're an admin of |
|
526 | Returns list of repositories you're an admin of | |
527 | """ |
|
527 | """ | |
528 |
return [x[0] for x in self.permissions['repositories']. |
|
528 | return [x[0] for x in self.permissions['repositories'].items() | |
529 | if x[1] == 'repository.admin'] |
|
529 | if x[1] == 'repository.admin'] | |
530 |
|
530 | |||
531 | @property |
|
531 | @property | |
@@ -533,7 +533,7 b' class AuthUser(object):' | |||||
533 | """ |
|
533 | """ | |
534 | Returns list of repository groups you're an admin of |
|
534 | Returns list of repository groups you're an admin of | |
535 | """ |
|
535 | """ | |
536 |
return [x[0] for x in self.permissions['repositories_groups']. |
|
536 | return [x[0] for x in self.permissions['repositories_groups'].items() | |
537 | if x[1] == 'group.admin'] |
|
537 | if x[1] == 'group.admin'] | |
538 |
|
538 | |||
539 | @property |
|
539 | @property | |
@@ -541,7 +541,7 b' class AuthUser(object):' | |||||
541 | """ |
|
541 | """ | |
542 | Returns list of user groups you're an admin of |
|
542 | Returns list of user groups you're an admin of | |
543 | """ |
|
543 | """ | |
544 |
return [x[0] for x in self.permissions['user_groups']. |
|
544 | return [x[0] for x in self.permissions['user_groups'].items() | |
545 | if x[1] == 'usergroup.admin'] |
|
545 | if x[1] == 'usergroup.admin'] | |
546 |
|
546 | |||
547 | def __repr__(self): |
|
547 | def __repr__(self): |
@@ -397,7 +397,7 b' class DiffProcessor(object):' | |||||
397 | 'new_lineno': '', |
|
397 | 'new_lineno': '', | |
398 | 'action': 'context', |
|
398 | 'action': 'context', | |
399 | 'line': msg, |
|
399 | 'line': msg, | |
400 |
} for _op, msg in stats['ops']. |
|
400 | } for _op, msg in stats['ops'].items() | |
401 | if _op not in [MOD_FILENODE]]) |
|
401 | if _op not in [MOD_FILENODE]]) | |
402 |
|
402 | |||
403 | _files.append({ |
|
403 | _files.append({ |
@@ -219,7 +219,7 b' class MarkupRenderer(object):' | |||||
219 | docutils_settings.update({'input_encoding': 'unicode', |
|
219 | docutils_settings.update({'input_encoding': 'unicode', | |
220 | 'report_level': 4}) |
|
220 | 'report_level': 4}) | |
221 |
|
221 | |||
222 |
for k, v in docutils_settings. |
|
222 | for k, v in docutils_settings.items(): | |
223 | directives.register_directive(k, v) |
|
223 | directives.register_directive(k, v) | |
224 |
|
224 | |||
225 | parts = publish_parts(source=source, |
|
225 | parts = publish_parts(source=source, |
@@ -79,7 +79,7 b' class GitChangeset(BaseChangeset):' | |||||
79 | @LazyProperty |
|
79 | @LazyProperty | |
80 | def tags(self): |
|
80 | def tags(self): | |
81 | _tags = [] |
|
81 | _tags = [] | |
82 |
for tname, tsha in self.repository.tags. |
|
82 | for tname, tsha in self.repository.tags.items(): | |
83 | if tsha == self.raw_id: |
|
83 | if tsha == self.raw_id: | |
84 | _tags.append(tname) |
|
84 | _tags.append(tname) | |
85 | return _tags |
|
85 | return _tags | |
@@ -123,7 +123,7 b' class GitChangeset(BaseChangeset):' | |||||
123 | curdir = '' |
|
123 | curdir = '' | |
124 |
|
124 | |||
125 | # initially extract things from root dir |
|
125 | # initially extract things from root dir | |
126 |
for item, stat, id in tree. |
|
126 | for item, stat, id in tree.items(): | |
127 | if curdir: |
|
127 | if curdir: | |
128 | name = '/'.join((curdir, item)) |
|
128 | name = '/'.join((curdir, item)) | |
129 | else: |
|
129 | else: | |
@@ -137,7 +137,7 b' class GitChangeset(BaseChangeset):' | |||||
137 | else: |
|
137 | else: | |
138 | curdir = dir |
|
138 | curdir = dir | |
139 | dir_id = None |
|
139 | dir_id = None | |
140 |
for item, stat, id in tree. |
|
140 | for item, stat, id in tree.items(): | |
141 | if dir == item: |
|
141 | if dir == item: | |
142 | dir_id = id |
|
142 | dir_id = id | |
143 | if dir_id: |
|
143 | if dir_id: | |
@@ -149,7 +149,7 b' class GitChangeset(BaseChangeset):' | |||||
149 | raise ChangesetError('%s have not been found' % curdir) |
|
149 | raise ChangesetError('%s have not been found' % curdir) | |
150 |
|
150 | |||
151 | # cache all items from the given traversed tree |
|
151 | # cache all items from the given traversed tree | |
152 |
for item, stat, id in tree. |
|
152 | for item, stat, id in tree.items(): | |
153 | if curdir: |
|
153 | if curdir: | |
154 | name = '/'.join((curdir, item)) |
|
154 | name = '/'.join((curdir, item)) | |
155 | else: |
|
155 | else: | |
@@ -407,7 +407,7 b' class GitChangeset(BaseChangeset):' | |||||
407 | dirnodes = [] |
|
407 | dirnodes = [] | |
408 | filenodes = [] |
|
408 | filenodes = [] | |
409 | als = self.repository.alias |
|
409 | als = self.repository.alias | |
410 |
for name, stat, id in tree. |
|
410 | for name, stat, id in tree.items(): | |
411 | if path != '': |
|
411 | if path != '': | |
412 | obj_path = '/'.join((path, name)) |
|
412 | obj_path = '/'.join((path, name)) | |
413 | else: |
|
413 | else: |
@@ -172,7 +172,7 b' class GitInMemoryChangeset(BaseInMemoryC' | |||||
172 | return [] |
|
172 | return [] | |
173 |
|
173 | |||
174 | def get_tree_for_dir(tree, dirname): |
|
174 | def get_tree_for_dir(tree, dirname): | |
175 |
for name, mode, id in tree. |
|
175 | for name, mode, id in tree.items(): | |
176 | if name == dirname: |
|
176 | if name == dirname: | |
177 | obj = self.repository._repo[id] |
|
177 | obj = self.repository._repo[id] | |
178 | if isinstance(obj, objects.Tree): |
|
178 | if isinstance(obj, objects.Tree): |
@@ -252,7 +252,7 b' class GitRepository(BaseRepository):' | |||||
252 |
|
252 | |||
253 | def _get_all_revisions2(self): |
|
253 | def _get_all_revisions2(self): | |
254 | # alternate implementation using dulwich |
|
254 | # alternate implementation using dulwich | |
255 |
includes = [ascii_str(sha) for key, (sha, type_) in self._parsed_refs. |
|
255 | includes = [ascii_str(sha) for key, (sha, type_) in self._parsed_refs.items() | |
256 | if type_ != b'T'] |
|
256 | if type_ != b'T'] | |
257 | return [c.commit.id for c in self._repo.get_walker(include=includes)] |
|
257 | return [c.commit.id for c in self._repo.get_walker(include=includes)] | |
258 |
|
258 | |||
@@ -360,7 +360,7 b' class GitRepository(BaseRepository):' | |||||
360 | return {} |
|
360 | return {} | |
361 | sortkey = lambda ctx: ctx[0] |
|
361 | sortkey = lambda ctx: ctx[0] | |
362 | _branches = [(key, ascii_str(sha)) |
|
362 | _branches = [(key, ascii_str(sha)) | |
363 |
for key, (sha, type_) in self._parsed_refs. |
|
363 | for key, (sha, type_) in self._parsed_refs.items() if type_ == b'H'] | |
364 | return OrderedDict(sorted(_branches, key=sortkey, reverse=False)) |
|
364 | return OrderedDict(sorted(_branches, key=sortkey, reverse=False)) | |
365 |
|
365 | |||
366 | @LazyProperty |
|
366 | @LazyProperty | |
@@ -377,7 +377,7 b' class GitRepository(BaseRepository):' | |||||
377 |
|
377 | |||
378 | sortkey = lambda ctx: ctx[0] |
|
378 | sortkey = lambda ctx: ctx[0] | |
379 | _tags = [(key, ascii_str(sha)) |
|
379 | _tags = [(key, ascii_str(sha)) | |
380 |
for key, (sha, type_) in self._parsed_refs. |
|
380 | for key, (sha, type_) in self._parsed_refs.items() if type_ == b'T'] | |
381 | return OrderedDict(sorted(_tags, key=sortkey, reverse=True)) |
|
381 | return OrderedDict(sorted(_tags, key=sortkey, reverse=True)) | |
382 |
|
382 | |||
383 | def tag(self, name, user, revision=None, message=None, date=None, |
|
383 | def tag(self, name, user, revision=None, message=None, date=None, | |
@@ -447,7 +447,7 b' class GitRepository(BaseRepository):' | |||||
447 | (b'refs/remotes/origin/', b'RH'), |
|
447 | (b'refs/remotes/origin/', b'RH'), | |
448 | (b'refs/tags/', b'T')] |
|
448 | (b'refs/tags/', b'T')] | |
449 | _refs = {} |
|
449 | _refs = {} | |
450 |
for ref, sha in refs. |
|
450 | for ref, sha in refs.items(): | |
451 | for k, type_ in keys: |
|
451 | for k, type_ in keys: | |
452 | if ref.startswith(k): |
|
452 | if ref.startswith(k): | |
453 | _key = ref[len(k):] |
|
453 | _key = ref[len(k):] | |
@@ -470,7 +470,7 b' class GitRepository(BaseRepository):' | |||||
470 | if n not in [b'HEAD']: |
|
470 | if n not in [b'HEAD']: | |
471 | heads[n] = val |
|
471 | heads[n] = val | |
472 |
|
472 | |||
473 |
return heads if reverse else dict((y, x) for x, y in heads. |
|
473 | return heads if reverse else dict((y, x) for x, y in heads.items()) | |
474 |
|
474 | |||
475 | def get_changeset(self, revision=None): |
|
475 | def get_changeset(self, revision=None): | |
476 | """ |
|
476 | """ |
@@ -340,7 +340,7 b' class MercurialChangeset(BaseChangeset):' | |||||
340 | if os.path.dirname(d) == path] |
|
340 | if os.path.dirname(d) == path] | |
341 |
|
341 | |||
342 | als = self.repository.alias |
|
342 | als = self.repository.alias | |
343 |
for k, vals in self._extract_submodules(). |
|
343 | for k, vals in self._extract_submodules().items(): | |
344 | #vals = url,rev,type |
|
344 | #vals = url,rev,type | |
345 | loc = vals[0] |
|
345 | loc = vals[0] | |
346 | cs = vals[1] |
|
346 | cs = vals[1] |
@@ -215,7 +215,7 b" def colorize(text='', opts=(), **kwargs)" | |||||
215 | code_list = [] |
|
215 | code_list = [] | |
216 | if text == '' and len(opts) == 1 and opts[0] == 'reset': |
|
216 | if text == '' and len(opts) == 1 and opts[0] == 'reset': | |
217 | return '\x1b[%sm' % RESET |
|
217 | return '\x1b[%sm' % RESET | |
218 |
for k, v in kwargs. |
|
218 | for k, v in kwargs.items(): | |
219 | if k == 'fg': |
|
219 | if k == 'fg': | |
220 | code_list.append(foreground[v]) |
|
220 | code_list.append(foreground[v]) | |
221 | elif k == 'bg': |
|
221 | elif k == 'bg': |
@@ -44,7 +44,7 b" def colorize(text='', opts=(), **kwargs)" | |||||
44 | code_list = [] |
|
44 | code_list = [] | |
45 | if text == '' and len(opts) == 1 and opts[0] == 'reset': |
|
45 | if text == '' and len(opts) == 1 and opts[0] == 'reset': | |
46 | return '\x1b[%sm' % RESET |
|
46 | return '\x1b[%sm' % RESET | |
47 |
for k, v in kwargs. |
|
47 | for k, v in kwargs.items(): | |
48 | if k == 'fg': |
|
48 | if k == 'fg': | |
49 | code_list.append(foreground[v]) |
|
49 | code_list.append(foreground[v]) | |
50 | elif k == 'bg': |
|
50 | elif k == 'bg': |
@@ -94,7 +94,7 b' class BaseDbModel(object):' | |||||
94 | # update with attributes from __json__ |
|
94 | # update with attributes from __json__ | |
95 | if callable(_json_attr): |
|
95 | if callable(_json_attr): | |
96 | _json_attr = _json_attr() |
|
96 | _json_attr = _json_attr() | |
97 |
for k, val in _json_attr. |
|
97 | for k, val in _json_attr.items(): | |
98 | d[k] = val |
|
98 | d[k] = val | |
99 | return d |
|
99 | return d | |
100 |
|
100 |
@@ -671,18 +671,18 b' class ScmModel(object):' | |||||
671 | repo = repo.scm_instance |
|
671 | repo = repo.scm_instance | |
672 |
|
672 | |||
673 | branches_group = ([(u'branch:%s' % k, k) for k, v in |
|
673 | branches_group = ([(u'branch:%s' % k, k) for k, v in | |
674 |
repo.branches. |
|
674 | repo.branches.items()], _("Branches")) | |
675 | hist_l.append(branches_group) |
|
675 | hist_l.append(branches_group) | |
676 | choices.extend([x[0] for x in branches_group[0]]) |
|
676 | choices.extend([x[0] for x in branches_group[0]]) | |
677 |
|
677 | |||
678 | if repo.alias == 'hg': |
|
678 | if repo.alias == 'hg': | |
679 | bookmarks_group = ([(u'book:%s' % k, k) for k, v in |
|
679 | bookmarks_group = ([(u'book:%s' % k, k) for k, v in | |
680 |
repo.bookmarks. |
|
680 | repo.bookmarks.items()], _("Bookmarks")) | |
681 | hist_l.append(bookmarks_group) |
|
681 | hist_l.append(bookmarks_group) | |
682 | choices.extend([x[0] for x in bookmarks_group[0]]) |
|
682 | choices.extend([x[0] for x in bookmarks_group[0]]) | |
683 |
|
683 | |||
684 | tags_group = ([(u'tag:%s' % k, k) for k, v in |
|
684 | tags_group = ([(u'tag:%s' % k, k) for k, v in | |
685 |
repo.tags. |
|
685 | repo.tags.items()], _("Tags")) | |
686 | hist_l.append(tags_group) |
|
686 | hist_l.append(tags_group) | |
687 | choices.extend([x[0] for x in tags_group[0]]) |
|
687 | choices.extend([x[0] for x in tags_group[0]]) | |
688 |
|
688 |
@@ -544,7 +544,7 b" def ValidPerms(type_='repo'):" | |||||
544 |
|
544 | |||
545 | # CLEAN OUT ORG VALUE FROM NEW MEMBERS, and group them using |
|
545 | # CLEAN OUT ORG VALUE FROM NEW MEMBERS, and group them using | |
546 | new_perms_group = defaultdict(dict) |
|
546 | new_perms_group = defaultdict(dict) | |
547 |
for k, v in value.copy(). |
|
547 | for k, v in value.copy().items(): | |
548 | if k.startswith('perm_new_member'): |
|
548 | if k.startswith('perm_new_member'): | |
549 | del value[k] |
|
549 | del value[k] | |
550 | _type, part = k.split('perm_new_member_') |
|
550 | _type, part = k.split('perm_new_member_') | |
@@ -564,7 +564,7 b" def ValidPerms(type_='repo'):" | |||||
564 | if new_member and new_perm and new_type: |
|
564 | if new_member and new_perm and new_type: | |
565 | perms_new.add((new_member, new_perm, new_type)) |
|
565 | perms_new.add((new_member, new_perm, new_type)) | |
566 |
|
566 | |||
567 |
for k, v in value. |
|
567 | for k, v in value.items(): | |
568 | if k.startswith('u_perm_') or k.startswith('g_perm_'): |
|
568 | if k.startswith('u_perm_') or k.startswith('g_perm_'): | |
569 | member = k[7:] |
|
569 | member = k[7:] | |
570 | t = {'u': 'user', |
|
570 | t = {'u': 'user', |
@@ -163,7 +163,7 b'' | |||||
163 | ## original location of comments ... but the ones outside diff context remains here |
|
163 | ## original location of comments ... but the ones outside diff context remains here | |
164 | <div class="comments inline-comments"> |
|
164 | <div class="comments inline-comments"> | |
165 | %for f_path, lines in c.inline_comments: |
|
165 | %for f_path, lines in c.inline_comments: | |
166 |
%for line_no, comments in lines.ite |
|
166 | %for line_no, comments in lines.items(): | |
167 | <div class="comments-list-chunk" data-f_path="${f_path}" data-line_no="${line_no}" data-target-id="${h.safeid(h.safe_unicode(f_path))}_${line_no}"> |
|
167 | <div class="comments-list-chunk" data-f_path="${f_path}" data-line_no="${line_no}" data-target-id="${h.safeid(h.safe_unicode(f_path))}_${line_no}"> | |
168 | %for co in comments: |
|
168 | %for co in comments: | |
169 | ${comment_block(co)} |
|
169 | ${comment_block(co)} |
@@ -34,7 +34,7 b' class TestAdminController(base.TestContr' | |||||
34 | with open(os.path.join(FIXTURES, 'journal_dump.csv')) as f: |
|
34 | with open(os.path.join(FIXTURES, 'journal_dump.csv')) as f: | |
35 | for row in csv.DictReader(f): |
|
35 | for row in csv.DictReader(f): | |
36 | ul = UserLog() |
|
36 | ul = UserLog() | |
37 |
for k, v in row. |
|
37 | for k, v in row.items(): | |
38 | v = safe_unicode(v) |
|
38 | v = safe_unicode(v) | |
39 | if k == 'action_date': |
|
39 | if k == 'action_date': | |
40 | v = strptime(v) |
|
40 | v = strptime(v) |
@@ -119,11 +119,11 b' class _ChangesetsWithCommitsTestCaseixin' | |||||
119 | assert doc_changeset not in default_branch_changesets |
|
119 | assert doc_changeset not in default_branch_changesets | |
120 |
|
120 | |||
121 | def test_get_changeset_by_branch(self): |
|
121 | def test_get_changeset_by_branch(self): | |
122 |
for branch, sha in self.repo.branches. |
|
122 | for branch, sha in self.repo.branches.items(): | |
123 | assert sha == self.repo.get_changeset(branch).raw_id |
|
123 | assert sha == self.repo.get_changeset(branch).raw_id | |
124 |
|
124 | |||
125 | def test_get_changeset_by_tag(self): |
|
125 | def test_get_changeset_by_tag(self): | |
126 |
for tag, sha in self.repo.tags. |
|
126 | for tag, sha in self.repo.tags.items(): | |
127 | assert sha == self.repo.get_changeset(tag).raw_id |
|
127 | assert sha == self.repo.get_changeset(tag).raw_id | |
128 |
|
128 | |||
129 | def test_get_changeset_parents(self): |
|
129 | def test_get_changeset_parents(self): |
@@ -791,13 +791,13 b' class TestGitHooks(object):' | |||||
791 | Tests if hooks are installed in repository if they are missing. |
|
791 | Tests if hooks are installed in repository if they are missing. | |
792 | """ |
|
792 | """ | |
793 |
|
793 | |||
794 |
for hook, hook_path in self.kallithea_hooks. |
|
794 | for hook, hook_path in self.kallithea_hooks.items(): | |
795 | if os.path.exists(hook_path): |
|
795 | if os.path.exists(hook_path): | |
796 | os.remove(hook_path) |
|
796 | os.remove(hook_path) | |
797 |
|
797 | |||
798 | ScmModel().install_git_hooks(repo=self.repo) |
|
798 | ScmModel().install_git_hooks(repo=self.repo) | |
799 |
|
799 | |||
800 |
for hook, hook_path in self.kallithea_hooks. |
|
800 | for hook, hook_path in self.kallithea_hooks.items(): | |
801 | assert os.path.exists(hook_path) |
|
801 | assert os.path.exists(hook_path) | |
802 |
|
802 | |||
803 | def test_kallithea_hooks_updated(self): |
|
803 | def test_kallithea_hooks_updated(self): | |
@@ -805,13 +805,13 b' class TestGitHooks(object):' | |||||
805 | Tests if hooks are updated if they are Kallithea hooks already. |
|
805 | Tests if hooks are updated if they are Kallithea hooks already. | |
806 | """ |
|
806 | """ | |
807 |
|
807 | |||
808 |
for hook, hook_path in self.kallithea_hooks. |
|
808 | for hook, hook_path in self.kallithea_hooks.items(): | |
809 | with open(hook_path, "w") as f: |
|
809 | with open(hook_path, "w") as f: | |
810 | f.write("KALLITHEA_HOOK_VER=0.0.0\nJUST_BOGUS") |
|
810 | f.write("KALLITHEA_HOOK_VER=0.0.0\nJUST_BOGUS") | |
811 |
|
811 | |||
812 | ScmModel().install_git_hooks(repo=self.repo) |
|
812 | ScmModel().install_git_hooks(repo=self.repo) | |
813 |
|
813 | |||
814 |
for hook, hook_path in self.kallithea_hooks. |
|
814 | for hook, hook_path in self.kallithea_hooks.items(): | |
815 | with open(hook_path) as f: |
|
815 | with open(hook_path) as f: | |
816 | assert "JUST_BOGUS" not in f.read() |
|
816 | assert "JUST_BOGUS" not in f.read() | |
817 |
|
817 | |||
@@ -820,13 +820,13 b' class TestGitHooks(object):' | |||||
820 | Tests if hooks are left untouched if they are not Kallithea hooks. |
|
820 | Tests if hooks are left untouched if they are not Kallithea hooks. | |
821 | """ |
|
821 | """ | |
822 |
|
822 | |||
823 |
for hook, hook_path in self.kallithea_hooks. |
|
823 | for hook, hook_path in self.kallithea_hooks.items(): | |
824 | with open(hook_path, "w") as f: |
|
824 | with open(hook_path, "w") as f: | |
825 | f.write("#!/bin/bash\n#CUSTOM_HOOK") |
|
825 | f.write("#!/bin/bash\n#CUSTOM_HOOK") | |
826 |
|
826 | |||
827 | ScmModel().install_git_hooks(repo=self.repo) |
|
827 | ScmModel().install_git_hooks(repo=self.repo) | |
828 |
|
828 | |||
829 |
for hook, hook_path in self.kallithea_hooks. |
|
829 | for hook, hook_path in self.kallithea_hooks.items(): | |
830 | with open(hook_path) as f: |
|
830 | with open(hook_path) as f: | |
831 | assert "CUSTOM_HOOK" in f.read() |
|
831 | assert "CUSTOM_HOOK" in f.read() | |
832 |
|
832 | |||
@@ -835,12 +835,12 b' class TestGitHooks(object):' | |||||
835 | Tests if hooks are forcefully updated even though they are custom hooks. |
|
835 | Tests if hooks are forcefully updated even though they are custom hooks. | |
836 | """ |
|
836 | """ | |
837 |
|
837 | |||
838 |
for hook, hook_path in self.kallithea_hooks. |
|
838 | for hook, hook_path in self.kallithea_hooks.items(): | |
839 | with open(hook_path, "w") as f: |
|
839 | with open(hook_path, "w") as f: | |
840 | f.write("#!/bin/bash\n#CUSTOM_HOOK") |
|
840 | f.write("#!/bin/bash\n#CUSTOM_HOOK") | |
841 |
|
841 | |||
842 | ScmModel().install_git_hooks(repo=self.repo, force_create=True) |
|
842 | ScmModel().install_git_hooks(repo=self.repo, force_create=True) | |
843 |
|
843 | |||
844 |
for hook, hook_path in self.kallithea_hooks. |
|
844 | for hook, hook_path in self.kallithea_hooks.items(): | |
845 | with open(hook_path) as f: |
|
845 | with open(hook_path) as f: | |
846 | assert "KALLITHEA_HOOK_VER" in f.read() |
|
846 | assert "KALLITHEA_HOOK_VER" in f.read() |
General Comments 0
You need to be logged in to leave comments.
Login now