Show More
@@ -1,298 +1,297 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | # This program is free software: you can redistribute it and/or modify |
|
2 | # This program is free software: you can redistribute it and/or modify | |
3 | # it under the terms of the GNU General Public License as published by |
|
3 | # it under the terms of the GNU General Public License as published by | |
4 | # the Free Software Foundation, either version 3 of the License, or |
|
4 | # the Free Software Foundation, either version 3 of the License, or | |
5 | # (at your option) any later version. |
|
5 | # (at your option) any later version. | |
6 | # |
|
6 | # | |
7 | # This program is distributed in the hope that it will be useful, |
|
7 | # This program is distributed in the hope that it will be useful, | |
8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
10 | # GNU General Public License for more details. |
|
10 | # GNU General Public License for more details. | |
11 | # |
|
11 | # | |
12 | # You should have received a copy of the GNU General Public License |
|
12 | # You should have received a copy of the GNU General Public License | |
13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
14 |
|
14 | |||
15 | """ |
|
15 | """ | |
16 | Helpers for fixture generation |
|
16 | Helpers for fixture generation | |
17 | """ |
|
17 | """ | |
18 | import os |
|
18 | import os | |
19 | import time |
|
19 | import time | |
20 | from kallithea.tests import * |
|
20 | from kallithea.tests import * | |
21 | from kallithea.model.db import Repository, User, RepoGroup, UserGroup |
|
21 | from kallithea.model.db import Repository, User, RepoGroup, UserGroup | |
22 | from kallithea.model.meta import Session |
|
22 | from kallithea.model.meta import Session | |
23 | from kallithea.model.repo import RepoModel |
|
23 | from kallithea.model.repo import RepoModel | |
24 | from kallithea.model.user import UserModel |
|
24 | from kallithea.model.user import UserModel | |
25 | from kallithea.model.repo_group import RepoGroupModel |
|
25 | from kallithea.model.repo_group import RepoGroupModel | |
26 | from kallithea.model.user_group import UserGroupModel |
|
26 | from kallithea.model.user_group import UserGroupModel | |
27 | from kallithea.model.gist import GistModel |
|
27 | from kallithea.model.gist import GistModel | |
28 | from kallithea.model.scm import ScmModel |
|
28 | from kallithea.model.scm import ScmModel | |
29 | from kallithea.lib.vcs.backends.base import EmptyChangeset |
|
29 | from kallithea.lib.vcs.backends.base import EmptyChangeset | |
30 |
|
30 | |||
31 | dn = os.path.dirname |
|
31 | dn = os.path.dirname | |
32 | FIXTURES = os.path.join(dn(dn(os.path.abspath(__file__))), 'tests', 'fixtures') |
|
32 | FIXTURES = os.path.join(dn(dn(os.path.abspath(__file__))), 'tests', 'fixtures') | |
33 |
|
33 | |||
34 |
|
34 | |||
35 | def error_function(*args, **kwargs): |
|
35 | def error_function(*args, **kwargs): | |
36 | raise Exception('Total Crash !') |
|
36 | raise Exception('Total Crash !') | |
37 |
|
37 | |||
38 |
|
38 | |||
39 | class Fixture(object): |
|
39 | class Fixture(object): | |
40 |
|
40 | |||
41 | def __init__(self): |
|
41 | def __init__(self): | |
42 | pass |
|
42 | pass | |
43 |
|
43 | |||
44 | def anon_access(self, status): |
|
44 | def anon_access(self, status): | |
45 | """ |
|
45 | """ | |
46 | Context manager for controlling anonymous access. |
|
46 | Context manager for controlling anonymous access. | |
47 | Anon access will be set and committed, but restored again when exiting the block. |
|
47 | Anon access will be set and committed, but restored again when exiting the block. | |
48 |
|
48 | |||
49 | Usage: |
|
49 | Usage: | |
50 |
|
50 | |||
51 | fixture = Fixture() |
|
51 | fixture = Fixture() | |
52 | with fixture.anon_access(False): |
|
52 | with fixture.anon_access(False): | |
53 | stuff |
|
53 | stuff | |
54 | """ |
|
54 | """ | |
55 |
|
55 | |||
56 | class context(object): |
|
56 | class context(object): | |
57 | def __enter__(self): |
|
57 | def __enter__(self): | |
58 | anon = User.get_default_user() |
|
58 | anon = User.get_default_user() | |
59 | self._before = anon.active |
|
59 | self._before = anon.active | |
60 | anon.active = status |
|
60 | anon.active = status | |
61 | Session().add(anon) |
|
61 | Session().add(anon) | |
62 | Session().commit() |
|
62 | Session().commit() | |
63 | time.sleep(1.5) # hack: wait for beaker sql_cache_short to expire |
|
63 | time.sleep(1.5) # hack: wait for beaker sql_cache_short to expire | |
64 |
|
64 | |||
65 | def __exit__(self, exc_type, exc_val, exc_tb): |
|
65 | def __exit__(self, exc_type, exc_val, exc_tb): | |
66 | anon = User.get_default_user() |
|
66 | anon = User.get_default_user() | |
67 | anon.active = self._before |
|
67 | anon.active = self._before | |
68 | Session().add(anon) |
|
68 | Session().add(anon) | |
69 | Session().commit() |
|
69 | Session().commit() | |
70 |
|
70 | |||
71 | return context() |
|
71 | return context() | |
72 |
|
72 | |||
73 | def _get_repo_create_params(self, **custom): |
|
73 | def _get_repo_create_params(self, **custom): | |
74 | defs = dict( |
|
74 | defs = dict( | |
75 | repo_name=None, |
|
75 | repo_name=None, | |
76 | repo_type='hg', |
|
76 | repo_type='hg', | |
77 | clone_uri='', |
|
77 | clone_uri='', | |
78 | repo_group=u'-1', |
|
78 | repo_group=u'-1', | |
79 | repo_description='DESC', |
|
79 | repo_description='DESC', | |
80 | repo_private=False, |
|
80 | repo_private=False, | |
81 | repo_landing_rev='rev:tip', |
|
81 | repo_landing_rev='rev:tip', | |
82 | repo_copy_permissions=False, |
|
82 | repo_copy_permissions=False, | |
83 | repo_state=Repository.STATE_CREATED, |
|
83 | repo_state=Repository.STATE_CREATED, | |
84 | ) |
|
84 | ) | |
85 | defs.update(custom) |
|
85 | defs.update(custom) | |
86 | if 'repo_name_full' not in custom: |
|
86 | if 'repo_name_full' not in custom: | |
87 | defs.update({'repo_name_full': defs['repo_name']}) |
|
87 | defs.update({'repo_name_full': defs['repo_name']}) | |
88 |
|
88 | |||
89 | # fix the repo name if passed as repo_name_full |
|
89 | # fix the repo name if passed as repo_name_full | |
90 | if defs['repo_name']: |
|
90 | if defs['repo_name']: | |
91 | defs['repo_name'] = defs['repo_name'].split('/')[-1] |
|
91 | defs['repo_name'] = defs['repo_name'].split('/')[-1] | |
92 |
|
92 | |||
93 | return defs |
|
93 | return defs | |
94 |
|
94 | |||
95 | def _get_group_create_params(self, **custom): |
|
95 | def _get_group_create_params(self, **custom): | |
96 | defs = dict( |
|
96 | defs = dict( | |
97 | group_name=None, |
|
97 | group_name=None, | |
98 | group_description='DESC', |
|
98 | group_description='DESC', | |
99 | group_parent_id=None, |
|
99 | group_parent_id=None, | |
100 | perms_updates=[], |
|
100 | perms_updates=[], | |
101 | perms_new=[], |
|
101 | perms_new=[], | |
102 | enable_locking=False, |
|
102 | enable_locking=False, | |
103 | recursive=False |
|
103 | recursive=False | |
104 | ) |
|
104 | ) | |
105 | defs.update(custom) |
|
105 | defs.update(custom) | |
106 |
|
106 | |||
107 | return defs |
|
107 | return defs | |
108 |
|
108 | |||
109 | def _get_user_create_params(self, name, **custom): |
|
109 | def _get_user_create_params(self, name, **custom): | |
110 | defs = dict( |
|
110 | defs = dict( | |
111 | username=name, |
|
111 | username=name, | |
112 | password='qweqwe', |
|
112 | password='qweqwe', | |
113 | email='%s+test@example.com' % name, |
|
113 | email='%s+test@example.com' % name, | |
114 | firstname='TestUser', |
|
114 | firstname='TestUser', | |
115 | lastname='Test', |
|
115 | lastname='Test', | |
116 | active=True, |
|
116 | active=True, | |
117 | admin=False, |
|
117 | admin=False, | |
118 | extern_type='internal', |
|
118 | extern_type='internal', | |
119 | extern_name=None |
|
119 | extern_name=None | |
120 | ) |
|
120 | ) | |
121 | defs.update(custom) |
|
121 | defs.update(custom) | |
122 |
|
122 | |||
123 | return defs |
|
123 | return defs | |
124 |
|
124 | |||
125 | def _get_user_group_create_params(self, name, **custom): |
|
125 | def _get_user_group_create_params(self, name, **custom): | |
126 | defs = dict( |
|
126 | defs = dict( | |
127 | users_group_name=name, |
|
127 | users_group_name=name, | |
128 | user_group_description='DESC', |
|
128 | user_group_description='DESC', | |
129 | users_group_active=True, |
|
129 | users_group_active=True, | |
130 | user_group_data={}, |
|
130 | user_group_data={}, | |
131 | ) |
|
131 | ) | |
132 | defs.update(custom) |
|
132 | defs.update(custom) | |
133 |
|
133 | |||
134 | return defs |
|
134 | return defs | |
135 |
|
135 | |||
136 | def create_repo(self, name, **kwargs): |
|
136 | def create_repo(self, name, **kwargs): | |
137 | if 'skip_if_exists' in kwargs: |
|
137 | if 'skip_if_exists' in kwargs: | |
138 | del kwargs['skip_if_exists'] |
|
138 | del kwargs['skip_if_exists'] | |
139 | r = Repository.get_by_repo_name(name) |
|
139 | r = Repository.get_by_repo_name(name) | |
140 | if r: |
|
140 | if r: | |
141 | return r |
|
141 | return r | |
142 |
|
142 | |||
143 | if isinstance(kwargs.get('repo_group'), RepoGroup): |
|
143 | if isinstance(kwargs.get('repo_group'), RepoGroup): | |
144 | kwargs['repo_group'] = kwargs['repo_group'].group_id |
|
144 | kwargs['repo_group'] = kwargs['repo_group'].group_id | |
145 |
|
145 | |||
146 | form_data = self._get_repo_create_params(repo_name=name, **kwargs) |
|
146 | form_data = self._get_repo_create_params(repo_name=name, **kwargs) | |
147 | cur_user = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) |
|
147 | cur_user = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) | |
148 | RepoModel().create(form_data, cur_user) |
|
148 | RepoModel().create(form_data, cur_user) | |
149 | Session().commit() |
|
149 | Session().commit() | |
150 | return Repository.get_by_repo_name(name) |
|
150 | return Repository.get_by_repo_name(name) | |
151 |
|
151 | |||
152 | def create_fork(self, repo_to_fork, fork_name, **kwargs): |
|
152 | def create_fork(self, repo_to_fork, fork_name, **kwargs): | |
153 | repo_to_fork = Repository.get_by_repo_name(repo_to_fork) |
|
153 | repo_to_fork = Repository.get_by_repo_name(repo_to_fork) | |
154 |
|
154 | |||
155 | form_data = self._get_repo_create_params(repo_name=fork_name, |
|
155 | form_data = self._get_repo_create_params(repo_name=fork_name, | |
156 | fork_parent_id=repo_to_fork, |
|
156 | fork_parent_id=repo_to_fork, | |
157 | repo_type=repo_to_fork.repo_type, |
|
157 | repo_type=repo_to_fork.repo_type, | |
158 | **kwargs) |
|
158 | **kwargs) | |
159 | form_data['update_after_clone'] = False |
|
159 | form_data['update_after_clone'] = False | |
160 |
|
160 | |||
161 | #TODO: fix it !! |
|
161 | #TODO: fix it !! | |
162 | form_data['description'] = form_data['repo_description'] |
|
162 | form_data['description'] = form_data['repo_description'] | |
163 | form_data['private'] = form_data['repo_private'] |
|
163 | form_data['private'] = form_data['repo_private'] | |
164 | form_data['landing_rev'] = form_data['repo_landing_rev'] |
|
164 | form_data['landing_rev'] = form_data['repo_landing_rev'] | |
165 |
|
165 | |||
166 | owner = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) |
|
166 | owner = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) | |
167 | RepoModel().create_fork(form_data, cur_user=owner) |
|
167 | RepoModel().create_fork(form_data, cur_user=owner) | |
168 | Session().commit() |
|
168 | Session().commit() | |
169 | r = Repository.get_by_repo_name(fork_name) |
|
169 | r = Repository.get_by_repo_name(fork_name) | |
170 | assert r |
|
170 | assert r | |
171 | return r |
|
171 | return r | |
172 |
|
172 | |||
173 | def destroy_repo(self, repo_name, **kwargs): |
|
173 | def destroy_repo(self, repo_name, **kwargs): | |
174 | RepoModel().delete(repo_name, **kwargs) |
|
174 | RepoModel().delete(repo_name, **kwargs) | |
175 | Session().commit() |
|
175 | Session().commit() | |
176 |
|
176 | |||
177 | def create_repo_group(self, name, **kwargs): |
|
177 | def create_repo_group(self, name, **kwargs): | |
178 | if 'skip_if_exists' in kwargs: |
|
178 | if 'skip_if_exists' in kwargs: | |
179 | del kwargs['skip_if_exists'] |
|
179 | del kwargs['skip_if_exists'] | |
180 | gr = RepoGroup.get_by_group_name(group_name=name) |
|
180 | gr = RepoGroup.get_by_group_name(group_name=name) | |
181 | if gr: |
|
181 | if gr: | |
182 | return gr |
|
182 | return gr | |
183 | form_data = self._get_group_create_params(group_name=name, **kwargs) |
|
183 | form_data = self._get_group_create_params(group_name=name, **kwargs) | |
184 | owner = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) |
|
184 | owner = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) | |
185 | gr = RepoGroupModel().create( |
|
185 | gr = RepoGroupModel().create( | |
186 | group_name=form_data['group_name'], |
|
186 | group_name=form_data['group_name'], | |
187 | group_description=form_data['group_name'], |
|
187 | group_description=form_data['group_name'], | |
188 | owner=owner, parent=form_data['group_parent_id']) |
|
188 | owner=owner, parent=form_data['group_parent_id']) | |
189 | Session().commit() |
|
189 | Session().commit() | |
190 | gr = RepoGroup.get_by_group_name(gr.group_name) |
|
190 | gr = RepoGroup.get_by_group_name(gr.group_name) | |
191 | return gr |
|
191 | return gr | |
192 |
|
192 | |||
193 | def destroy_repo_group(self, repogroupid): |
|
193 | def destroy_repo_group(self, repogroupid): | |
194 | RepoGroupModel().delete(repogroupid) |
|
194 | RepoGroupModel().delete(repogroupid) | |
195 | Session().commit() |
|
195 | Session().commit() | |
196 |
|
196 | |||
197 | def create_user(self, name, **kwargs): |
|
197 | def create_user(self, name, **kwargs): | |
198 | if 'skip_if_exists' in kwargs: |
|
198 | if 'skip_if_exists' in kwargs: | |
199 | del kwargs['skip_if_exists'] |
|
199 | del kwargs['skip_if_exists'] | |
200 | user = User.get_by_username(name) |
|
200 | user = User.get_by_username(name) | |
201 | if user: |
|
201 | if user: | |
202 | return user |
|
202 | return user | |
203 | form_data = self._get_user_create_params(name, **kwargs) |
|
203 | form_data = self._get_user_create_params(name, **kwargs) | |
204 | user = UserModel().create(form_data) |
|
204 | user = UserModel().create(form_data) | |
205 | Session().commit() |
|
205 | Session().commit() | |
206 | user = User.get_by_username(user.username) |
|
206 | user = User.get_by_username(user.username) | |
207 | return user |
|
207 | return user | |
208 |
|
208 | |||
209 | def destroy_user(self, userid): |
|
209 | def destroy_user(self, userid): | |
210 | UserModel().delete(userid) |
|
210 | UserModel().delete(userid) | |
211 | Session().commit() |
|
211 | Session().commit() | |
212 |
|
212 | |||
213 | def create_user_group(self, name, **kwargs): |
|
213 | def create_user_group(self, name, **kwargs): | |
214 | if 'skip_if_exists' in kwargs: |
|
214 | if 'skip_if_exists' in kwargs: | |
215 | del kwargs['skip_if_exists'] |
|
215 | del kwargs['skip_if_exists'] | |
216 | gr = UserGroup.get_by_group_name(group_name=name) |
|
216 | gr = UserGroup.get_by_group_name(group_name=name) | |
217 | if gr: |
|
217 | if gr: | |
218 | return gr |
|
218 | return gr | |
219 | form_data = self._get_user_group_create_params(name, **kwargs) |
|
219 | form_data = self._get_user_group_create_params(name, **kwargs) | |
220 | owner = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) |
|
220 | owner = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) | |
221 | user_group = UserGroupModel().create( |
|
221 | user_group = UserGroupModel().create( | |
222 | name=form_data['users_group_name'], |
|
222 | name=form_data['users_group_name'], | |
223 | description=form_data['user_group_description'], |
|
223 | description=form_data['user_group_description'], | |
224 | owner=owner, active=form_data['users_group_active'], |
|
224 | owner=owner, active=form_data['users_group_active'], | |
225 | group_data=form_data['user_group_data']) |
|
225 | group_data=form_data['user_group_data']) | |
226 | Session().commit() |
|
226 | Session().commit() | |
227 | user_group = UserGroup.get_by_group_name(user_group.users_group_name) |
|
227 | user_group = UserGroup.get_by_group_name(user_group.users_group_name) | |
228 | return user_group |
|
228 | return user_group | |
229 |
|
229 | |||
230 | def destroy_user_group(self, usergroupid): |
|
230 | def destroy_user_group(self, usergroupid): | |
231 | UserGroupModel().delete(user_group=usergroupid, force=True) |
|
231 | UserGroupModel().delete(user_group=usergroupid, force=True) | |
232 | Session().commit() |
|
232 | Session().commit() | |
233 |
|
233 | |||
234 | def create_gist(self, **kwargs): |
|
234 | def create_gist(self, **kwargs): | |
235 | form_data = { |
|
235 | form_data = { | |
236 | 'description': u'new-gist', |
|
236 | 'description': u'new-gist', | |
237 | 'owner': TEST_USER_ADMIN_LOGIN, |
|
237 | 'owner': TEST_USER_ADMIN_LOGIN, | |
238 | 'gist_type': GistModel.cls.GIST_PUBLIC, |
|
238 | 'gist_type': GistModel.cls.GIST_PUBLIC, | |
239 | 'lifetime': -1, |
|
239 | 'lifetime': -1, | |
240 | 'gist_mapping': {'filename1.txt':{'content':'hello world'},} |
|
240 | 'gist_mapping': {'filename1.txt':{'content':'hello world'},} | |
241 | } |
|
241 | } | |
242 | form_data.update(kwargs) |
|
242 | form_data.update(kwargs) | |
243 | gist = GistModel().create( |
|
243 | gist = GistModel().create( | |
244 | description=form_data['description'],owner=form_data['owner'], |
|
244 | description=form_data['description'],owner=form_data['owner'], | |
245 | gist_mapping=form_data['gist_mapping'], gist_type=form_data['gist_type'], |
|
245 | gist_mapping=form_data['gist_mapping'], gist_type=form_data['gist_type'], | |
246 | lifetime=form_data['lifetime'] |
|
246 | lifetime=form_data['lifetime'] | |
247 | ) |
|
247 | ) | |
248 | Session().commit() |
|
248 | Session().commit() | |
249 |
|
249 | |||
250 | return gist |
|
250 | return gist | |
251 |
|
251 | |||
252 | def destroy_gists(self, gistid=None): |
|
252 | def destroy_gists(self, gistid=None): | |
253 | for g in GistModel.cls.get_all(): |
|
253 | for g in GistModel.cls.get_all(): | |
254 | if gistid: |
|
254 | if gistid: | |
255 | if gistid == g.gist_access_id: |
|
255 | if gistid == g.gist_access_id: | |
256 | GistModel().delete(g) |
|
256 | GistModel().delete(g) | |
257 | else: |
|
257 | else: | |
258 | GistModel().delete(g) |
|
258 | GistModel().delete(g) | |
259 | Session().commit() |
|
259 | Session().commit() | |
260 |
|
260 | |||
261 | def load_resource(self, resource_name, strip=True): |
|
261 | def load_resource(self, resource_name, strip=True): | |
262 | with open(os.path.join(FIXTURES, resource_name)) as f: |
|
262 | with open(os.path.join(FIXTURES, resource_name)) as f: | |
263 | source = f.read() |
|
263 | source = f.read() | |
264 | if strip: |
|
264 | if strip: | |
265 | source = source.strip() |
|
265 | source = source.strip() | |
266 |
|
266 | |||
267 | return source |
|
267 | return source | |
268 |
|
268 | |||
269 | def commit_change(self, repo, filename, content, message, vcs_type, parent=None, newfile=False): |
|
269 | def commit_change(self, repo, filename, content, message, vcs_type, parent=None, newfile=False): | |
270 | repo = Repository.get_by_repo_name(repo) |
|
270 | repo = Repository.get_by_repo_name(repo) | |
271 | _cs = parent |
|
271 | _cs = parent | |
272 | if not parent: |
|
272 | if not parent: | |
273 | _cs = EmptyChangeset(alias=vcs_type) |
|
273 | _cs = EmptyChangeset(alias=vcs_type) | |
274 |
|
274 | |||
275 | if newfile: |
|
275 | if newfile: | |
276 | nodes = { |
|
276 | nodes = { | |
277 | filename: { |
|
277 | filename: { | |
278 | 'content': content |
|
278 | 'content': content | |
279 | } |
|
279 | } | |
280 | } |
|
280 | } | |
281 | cs = ScmModel().create_nodes( |
|
281 | cs = ScmModel().create_nodes( | |
282 | user=TEST_USER_ADMIN_LOGIN, repo=repo, |
|
282 | user=TEST_USER_ADMIN_LOGIN, repo=repo, | |
283 | message=message, |
|
283 | message=message, | |
284 | nodes=nodes, |
|
284 | nodes=nodes, | |
285 | parent_cs=_cs, |
|
285 | parent_cs=_cs, | |
286 | author=TEST_USER_ADMIN_LOGIN, |
|
286 | author=TEST_USER_ADMIN_LOGIN, | |
287 | ) |
|
287 | ) | |
288 | else: |
|
288 | else: | |
289 | cs = ScmModel().commit_change( |
|
289 | cs = ScmModel().commit_change( | |
290 | repo=repo.scm_instance, repo_name=repo.repo_name, |
|
290 | repo=repo.scm_instance, repo_name=repo.repo_name, | |
291 | cs=parent, user=TEST_USER_ADMIN_LOGIN, |
|
291 | cs=parent, user=TEST_USER_ADMIN_LOGIN, | |
292 | author=TEST_USER_ADMIN_LOGIN, |
|
292 | author=TEST_USER_ADMIN_LOGIN, | |
293 | message=message, |
|
293 | message=message, | |
294 | content=content, |
|
294 | content=content, | |
295 | f_path=filename |
|
295 | f_path=filename | |
296 | ) |
|
296 | ) | |
297 | return cs |
|
297 | return cs | |
298 |
|
@@ -1,20 +1,20 b'' | |||||
1 | #!/bin/bash -x |
|
1 | #!/bin/bash -x | |
2 |
|
2 | |||
3 | # Enforce some consistency in whitespace - just to avoid spurious whitespaces changes |
|
3 | # Enforce some consistency in whitespace - just to avoid spurious whitespaces changes | |
4 |
|
4 | |||
5 | files=`hg loc '*.py' '*.html' '*.css' '*.rst' '*.txt' '*.js' | egrep -v '/lockfiles.py|LICENSE-MERGELY.html|/codemirror/|/fontello/|(graph|mergely|native.history|select2/select2|yui.flot|yui.2.9)\.js$'` |
|
5 | files=`hg loc '*.py' '*.html' '*.css' '*.rst' '*.txt' '*.js' | egrep -v '/lockfiles.py|LICENSE-MERGELY.html|/codemirror/|/fontello/|(graph|mergely|native.history|select2/select2|yui.flot|yui.2.9)\.js$'` | |
6 | sed -i "s,`printf '\t'`, ,g" $files |
|
6 | sed -i -e "s,`printf '\t'`, ,g" $files | |
7 | sed -i "s, *$,,g" $files |
|
7 | sed -i -e "s, *$,,g" $files | |
8 | # add trailing newline if missing: |
|
8 | # ensure one trailing newline - remove empty last line and make last line include trailing newline: | |
9 | sed -i '$a\' $files |
|
9 | sed -i -e '$,${/^$/d}' -e '$a\' $files | |
10 |
|
10 | |||
11 | sed -i 's,\([^ /]\){,\1 {,g' `hg loc '*.css'` |
|
11 | sed -i -e 's,\([^ /]\){,\1 {,g' `hg loc '*.css'` | |
12 | sed -i 's|^\([^ /].*,\)\([^ ]\)|\1 \2|g' `hg loc '*.css'` |
|
12 | sed -i -e 's|^\([^ /].*,\)\([^ ]\)|\1 \2|g' `hg loc '*.css'` | |
13 |
|
13 | |||
14 | sed -i 's/^\( [^: ]*\) *: *\([^/]\)/\1: \2/g' kallithea/public/css/{style,contextbar}.css |
|
14 | sed -i -e 's/^\( [^: ]*\) *: *\([^/]\)/\1: \2/g' kallithea/public/css/{style,contextbar}.css | |
15 | sed -i '1s|, |,|g' kallithea/public/css/{style,contextbar}.css |
|
15 | sed -i -e '1s|, |,|g' kallithea/public/css/{style,contextbar}.css | |
16 | sed -i 's/^\([^ ,/]\+ [^,]*[^ ,]\) *, *\(.\)/\1,\n\2/g' kallithea/public/css/{style,contextbar}.css |
|
16 | sed -i -e 's/^\([^ ,/]\+ [^,]*[^ ,]\) *, *\(.\)/\1,\n\2/g' kallithea/public/css/{style,contextbar}.css | |
17 | sed -i 's/^\([^ ,/].*\) */\1 /g' kallithea/public/css/{style,contextbar}.css |
|
17 | sed -i -e 's/^\([^ ,/].*\) */\1 /g' kallithea/public/css/{style,contextbar}.css | |
18 | sed -i 's,^--$,-- ,g' kallithea/templates/email_templates/main.txt |
|
18 | sed -i -e 's,^--$,-- ,g' kallithea/templates/email_templates/main.txt | |
19 |
|
19 | |||
20 | hg diff |
|
20 | hg diff |
General Comments 0
You need to be logged in to leave comments.
Login now