##// END OF EJS Templates
repositories: allow properly updating repository push url.
marcink -
r2562:25341b46 default
parent child Browse files
Show More
@@ -563,6 +563,7 b' def create_repo('
563 description=Optional(''),
563 description=Optional(''),
564 private=Optional(False),
564 private=Optional(False),
565 clone_uri=Optional(None),
565 clone_uri=Optional(None),
566 push_uri=Optional(None),
566 landing_rev=Optional('rev:tip'),
567 landing_rev=Optional('rev:tip'),
567 enable_statistics=Optional(False),
568 enable_statistics=Optional(False),
568 enable_locking=Optional(False),
569 enable_locking=Optional(False),
@@ -596,6 +597,8 b' def create_repo('
596 :type private: bool
597 :type private: bool
597 :param clone_uri: set clone_uri
598 :param clone_uri: set clone_uri
598 :type clone_uri: str
599 :type clone_uri: str
600 :param push_uri: set push_uri
601 :type push_uri: str
599 :param landing_rev: <rev_type>:<rev>
602 :param landing_rev: <rev_type>:<rev>
600 :type landing_rev: str
603 :type landing_rev: str
601 :param enable_locking:
604 :param enable_locking:
@@ -639,6 +642,7 b' def create_repo('
639 description = Optional.extract(description)
642 description = Optional.extract(description)
640 copy_permissions = Optional.extract(copy_permissions)
643 copy_permissions = Optional.extract(copy_permissions)
641 clone_uri = Optional.extract(clone_uri)
644 clone_uri = Optional.extract(clone_uri)
645 push_uri = Optional.extract(push_uri)
642 landing_commit_ref = Optional.extract(landing_rev)
646 landing_commit_ref = Optional.extract(landing_rev)
643
647
644 defs = SettingsModel().get_default_repo_settings(strip_prefix=True)
648 defs = SettingsModel().get_default_repo_settings(strip_prefix=True)
@@ -666,6 +670,7 b' def create_repo('
666 repo_description=description,
670 repo_description=description,
667 repo_landing_commit_ref=landing_commit_ref,
671 repo_landing_commit_ref=landing_commit_ref,
668 repo_clone_uri=clone_uri,
672 repo_clone_uri=clone_uri,
673 repo_push_uri=push_uri,
669 repo_private=private,
674 repo_private=private,
670 repo_copy_permissions=copy_permissions,
675 repo_copy_permissions=copy_permissions,
671 repo_enable_statistics=enable_statistics,
676 repo_enable_statistics=enable_statistics,
@@ -684,6 +689,7 b' def create_repo('
684 'repo_description': schema_data['repo_description'],
689 'repo_description': schema_data['repo_description'],
685 'repo_private': schema_data['repo_private'],
690 'repo_private': schema_data['repo_private'],
686 'clone_uri': schema_data['repo_clone_uri'],
691 'clone_uri': schema_data['repo_clone_uri'],
692 'push_uri': schema_data['repo_push_uri'],
687 'repo_landing_rev': schema_data['repo_landing_commit_ref'],
693 'repo_landing_rev': schema_data['repo_landing_commit_ref'],
688 'enable_statistics': schema_data['repo_enable_statistics'],
694 'enable_statistics': schema_data['repo_enable_statistics'],
689 'enable_locking': schema_data['repo_enable_locking'],
695 'enable_locking': schema_data['repo_enable_locking'],
@@ -907,6 +913,7 b' def update_repo('
907 repo_owner=updates['user'],
913 repo_owner=updates['user'],
908 repo_description=updates['repo_description'],
914 repo_description=updates['repo_description'],
909 repo_clone_uri=updates['clone_uri'],
915 repo_clone_uri=updates['clone_uri'],
916 repo_push_uri=updates['push_uri'],
910 repo_fork_of=updates['fork_id'],
917 repo_fork_of=updates['fork_id'],
911 repo_private=updates['repo_private'],
918 repo_private=updates['repo_private'],
912 repo_landing_commit_ref=updates['repo_landing_rev'],
919 repo_landing_commit_ref=updates['repo_landing_rev'],
@@ -925,6 +932,7 b' def update_repo('
925 repo_description=schema_data['repo_description'],
932 repo_description=schema_data['repo_description'],
926 repo_private=schema_data['repo_private'],
933 repo_private=schema_data['repo_private'],
927 clone_uri=schema_data['repo_clone_uri'],
934 clone_uri=schema_data['repo_clone_uri'],
935 push_uri=schema_data['repo_push_uri'],
928 repo_landing_rev=schema_data['repo_landing_commit_ref'],
936 repo_landing_rev=schema_data['repo_landing_commit_ref'],
929 repo_enable_statistics=schema_data['repo_enable_statistics'],
937 repo_enable_statistics=schema_data['repo_enable_statistics'],
930 repo_enable_locking=schema_data['repo_enable_locking'],
938 repo_enable_locking=schema_data['repo_enable_locking'],
@@ -373,6 +373,9 b' def includeme(config):'
373 config.add_route(
373 config.add_route(
374 name='edit_repo_remote_pull',
374 name='edit_repo_remote_pull',
375 pattern='/{repo_name:.*?[^/]}/settings/remote/pull', repo_route=True)
375 pattern='/{repo_name:.*?[^/]}/settings/remote/pull', repo_route=True)
376 config.add_route(
377 name='edit_repo_remote_push',
378 pattern='/{repo_name:.*?[^/]}/settings/remote/push', repo_route=True)
376
379
377 # Statistics
380 # Statistics
378 config.add_route(
381 config.add_route(
@@ -138,15 +138,19 b' class RepoSettingsView(RepoAppView):'
138 repo_description=schema_data['repo_description'],
138 repo_description=schema_data['repo_description'],
139 repo_private=schema_data['repo_private'],
139 repo_private=schema_data['repo_private'],
140 clone_uri=schema_data['repo_clone_uri'],
140 clone_uri=schema_data['repo_clone_uri'],
141 push_uri=schema_data['repo_push_uri'],
141 repo_landing_rev=schema_data['repo_landing_commit_ref'],
142 repo_landing_rev=schema_data['repo_landing_commit_ref'],
142 repo_enable_statistics=schema_data['repo_enable_statistics'],
143 repo_enable_statistics=schema_data['repo_enable_statistics'],
143 repo_enable_locking=schema_data['repo_enable_locking'],
144 repo_enable_locking=schema_data['repo_enable_locking'],
144 repo_enable_downloads=schema_data['repo_enable_downloads'],
145 repo_enable_downloads=schema_data['repo_enable_downloads'],
145 )
146 )
146 # detect if CLONE URI changed, if we get OLD means we keep old values
147 # detect if SYNC URI changed, if we get OLD means we keep old values
147 if schema_data['repo_clone_uri_change'] == 'OLD':
148 if schema_data['repo_clone_uri_change'] == 'OLD':
148 validated_updates['clone_uri'] = self.db_repo.clone_uri
149 validated_updates['clone_uri'] = self.db_repo.clone_uri
149
150
151 if schema_data['repo_push_uri_change'] == 'OLD':
152 validated_updates['push_uri'] = self.db_repo.push_uri
153
150 # use the new full name for redirect
154 # use the new full name for redirect
151 new_repo_name = schema_data['repo_group']['repo_name_with_group']
155 new_repo_name = schema_data['repo_group']['repo_name_with_group']
152
156
@@ -35,8 +35,6 b' log = logging.getLogger(__name__)'
35 class RepoSettingsRemoteView(RepoAppView):
35 class RepoSettingsRemoteView(RepoAppView):
36 def load_default_context(self):
36 def load_default_context(self):
37 c = self._get_local_tmpl_context()
37 c = self._get_local_tmpl_context()
38
39
40 return c
38 return c
41
39
42 @LoginRequired()
40 @LoginRequired()
@@ -304,6 +304,7 b' class RepoModel(BaseModel):'
304 {'k': 'repo_enable_locking', 'strip': True},
304 {'k': 'repo_enable_locking', 'strip': True},
305 {'k': 'repo_landing_rev', 'strip': True},
305 {'k': 'repo_landing_rev', 'strip': True},
306 {'k': 'clone_uri', 'strip': False},
306 {'k': 'clone_uri', 'strip': False},
307 {'k': 'push_uri', 'strip': False},
307 {'k': 'repo_private', 'strip': True},
308 {'k': 'repo_private', 'strip': True},
308 {'k': 'repo_enable_statistics', 'strip': True}
309 {'k': 'repo_enable_statistics', 'strip': True}
309 )
310 )
@@ -319,6 +320,8 b' class RepoModel(BaseModel):'
319 defaults[item['k']] = val
320 defaults[item['k']] = val
320 if item['k'] == 'clone_uri':
321 if item['k'] == 'clone_uri':
321 defaults['clone_uri_hidden'] = repo_info.clone_uri_hidden
322 defaults['clone_uri_hidden'] = repo_info.clone_uri_hidden
323 if item['k'] == 'push_uri':
324 defaults['push_uri_hidden'] = repo_info.push_uri_hidden
322
325
323 # fill owner
326 # fill owner
324 if repo_info.user:
327 if repo_info.user:
@@ -348,6 +351,7 b' class RepoModel(BaseModel):'
348 (1, 'repo_enable_locking'),
351 (1, 'repo_enable_locking'),
349 (1, 'repo_enable_statistics'),
352 (1, 'repo_enable_statistics'),
350 (0, 'clone_uri'),
353 (0, 'clone_uri'),
354 (0, 'push_uri'),
351 (0, 'fork_id')
355 (0, 'fork_id')
352 ]
356 ]
353 for strip, k in update_keys:
357 for strip, k in update_keys:
@@ -66,7 +66,7 b' def deferred_landing_ref_validator(node,'
66
66
67
67
68 @colander.deferred
68 @colander.deferred
69 def deferred_clone_uri_validator(node, kw):
69 def deferred_sync_uri_validator(node, kw):
70 repo_type = kw.get('repo_type')
70 repo_type = kw.get('repo_type')
71 validator = validators.CloneUriValidator(repo_type)
71 validator = validators.CloneUriValidator(repo_type)
72 return validator
72 return validator
@@ -323,6 +323,12 b' class RepoSchema(colander.MappingSchema)'
323 preparers=[preparers.strip_preparer],
323 preparers=[preparers.strip_preparer],
324 missing='')
324 missing='')
325
325
326 repo_push_uri = colander.SchemaNode(
327 colander.String(),
328 validator=colander.All(colander.Length(min=1)),
329 preparers=[preparers.strip_preparer],
330 missing='')
331
326 repo_fork_of = colander.SchemaNode(
332 repo_fork_of = colander.SchemaNode(
327 colander.String(),
333 colander.String(),
328 validator=deferred_fork_of_validator,
334 validator=deferred_fork_of_validator,
@@ -381,7 +387,17 b' class RepoSettingsSchema(RepoSchema):'
381 repo_clone_uri = colander.SchemaNode(
387 repo_clone_uri = colander.SchemaNode(
382 colander.String(),
388 colander.String(),
383 preparers=[preparers.strip_preparer],
389 preparers=[preparers.strip_preparer],
384 validator=deferred_clone_uri_validator,
390 validator=deferred_sync_uri_validator,
391 missing='')
392
393 repo_push_uri_change = colander.SchemaNode(
394 colander.String(),
395 missing='NEW')
396
397 repo_push_uri = colander.SchemaNode(
398 colander.String(),
399 preparers=[preparers.strip_preparer],
400 validator=deferred_sync_uri_validator,
385 missing='')
401 missing='')
386
402
387 def deserialize(self, cstruct):
403 def deserialize(self, cstruct):
@@ -232,6 +232,7 b' function registerRCRoutes() {'
232 pyroutes.register('repo_edit_toggle_locking', '/%(repo_name)s/settings/toggle_locking', ['repo_name']);
232 pyroutes.register('repo_edit_toggle_locking', '/%(repo_name)s/settings/toggle_locking', ['repo_name']);
233 pyroutes.register('edit_repo_remote', '/%(repo_name)s/settings/remote', ['repo_name']);
233 pyroutes.register('edit_repo_remote', '/%(repo_name)s/settings/remote', ['repo_name']);
234 pyroutes.register('edit_repo_remote_pull', '/%(repo_name)s/settings/remote/pull', ['repo_name']);
234 pyroutes.register('edit_repo_remote_pull', '/%(repo_name)s/settings/remote/pull', ['repo_name']);
235 pyroutes.register('edit_repo_remote_push', '/%(repo_name)s/settings/remote/push', ['repo_name']);
235 pyroutes.register('edit_repo_statistics', '/%(repo_name)s/settings/statistics', ['repo_name']);
236 pyroutes.register('edit_repo_statistics', '/%(repo_name)s/settings/statistics', ['repo_name']);
236 pyroutes.register('edit_repo_statistics_reset', '/%(repo_name)s/settings/statistics/update', ['repo_name']);
237 pyroutes.register('edit_repo_statistics_reset', '/%(repo_name)s/settings/statistics/update', ['repo_name']);
237 pyroutes.register('edit_repo_issuetracker', '/%(repo_name)s/settings/issue_trackers', ['repo_name']);
238 pyroutes.register('edit_repo_issuetracker', '/%(repo_name)s/settings/issue_trackers', ['repo_name']);
@@ -65,7 +65,7 b''
65 </li>
65 </li>
66 %if c.rhodecode_db_repo.repo_type != 'svn':
66 %if c.rhodecode_db_repo.repo_type != 'svn':
67 <li class="${'active' if c.active=='remote' else ''}">
67 <li class="${'active' if c.active=='remote' else ''}">
68 <a href="${h.route_path('edit_repo_remote', repo_name=c.repo_name)}">${_('Remote')}</a>
68 <a href="${h.route_path('edit_repo_remote', repo_name=c.repo_name)}">${_('Remote sync')}</a>
69 </li>
69 </li>
70 %endif
70 %endif
71 <li class="${'active' if c.active=='statistics' else ''}">
71 <li class="${'active' if c.active=='statistics' else ''}">
@@ -1,31 +1,60 b''
1 <div class="panel panel-default">
1 <div class="panel panel-default">
2 <div class="panel-heading">
2 <div class="panel-heading">
3 <h3 class="panel-title">${_('Remote url')}</h3>
3 <h3 class="panel-title">${_('Remote Sync')}</h3>
4 </div>
4 </div>
5 <div class="panel-body">
5 <div class="panel-body">
6
6
7 <h4>${_('Manually pull changes from external repository.')}</h4>
7 <h4>${_('Manually pull/push changes from/to external URLs.')}</h4>
8
8
9 %if c.rhodecode_db_repo.clone_uri:
9 %if c.rhodecode_db_repo.clone_uri or c.rhodecode_db_repo.push_uri:
10
11 ${_('Remote mirror url')}:
12 <a href="${c.rhodecode_db_repo.clone_uri}">${c.rhodecode_db_repo.clone_uri_hidden}</a>
13
10
14 <p>
11 <table>
15 ${_('Pull can be automated by such api call. Can be called periodically in crontab etc.')}
12 % if c.rhodecode_db_repo.clone_uri:
16 <br/>
13 <tr>
17 <code>
14 <td><div style="min-width: 80px"><strong>${_('Pull url')}</strong></div></td>
18 ${h.api_call_example(method='pull', args={"repoid": c.rhodecode_db_repo.repo_name})}
15 <td><a href="${c.rhodecode_db_repo.clone_uri}">${c.rhodecode_db_repo.clone_uri_hidden}</a></td>
19 </code>
16 </tr>
20 </p>
17 <tr>
18 <td></td>
19 <td>
20 <p>
21 ${_('Pull can be automated by such api call. Can be called periodically in crontab etc.')}
22 <br/>
23 <code>
24 ${h.api_call_example(method='pull', args={"repoid": c.rhodecode_db_repo.repo_name})}
25 </code>
26 </p>
27 </td>
28 </tr>
29 <tr>
30 <td></td>
31 <td>
32 ${h.secure_form(h.route_path('edit_repo_remote_pull', repo_name=c.repo_name), request=request)}
33 <div class="form">
34 <div class="fields">
35 ${h.submit('remote_pull_%s' % c.rhodecode_db_repo.repo_name,_('Pull changes from remote location'),class_="btn btn-small",onclick="return confirm('"+_('Confirm to pull changes from remote side')+"');")}
36 </div>
37 </div>
38 ${h.end_form()}
39 </td>
40 </tr>
41 % endif
21
42
22 ${h.secure_form(h.route_path('edit_repo_remote_pull', repo_name=c.repo_name), request=request)}
43 % if c.rhodecode_db_repo.push_uri:
23 <div class="form">
44 <tr>
24 <div class="fields">
45 <td><div style="min-width: 80px"><strong>${_('Push url')}</strong></div></td>
25 ${h.submit('remote_pull_%s' % c.rhodecode_db_repo.repo_name,_('Pull changes from remote location'),class_="btn btn-small",onclick="return confirm('"+_('Confirm to pull changes from remote side')+"');")}
46 <td><a href="${c.rhodecode_db_repo.push_uri_hidden}">${c.rhodecode_db_repo.push_uri_hidden}</a></td>
26 </div>
47 </tr>
27 </div>
48 <tr>
28 ${h.end_form()}
49 <td></td>
50 <td>
51 ${_('This feature is available in RhodeCode EE edition only. Contact {sales_email} to obtain a trial license.').format(sales_email='<a href="mailto:sales@rhodecode.com">sales@rhodecode.com</a>')|n}
52 </td>
53 </tr>
54 % endif
55
56 </table>
57
29 %else:
58 %else:
30
59
31 ${_('This repository does not have any remote mirror url set.')}
60 ${_('This repository does not have any remote mirror url set.')}
@@ -46,9 +46,10 b''
46 </div>
46 </div>
47
47
48 % if c.rhodecode_db_repo.repo_type != 'svn':
48 % if c.rhodecode_db_repo.repo_type != 'svn':
49 <% sync_link = h.literal(h.link_to('remote sync', h.route_path('edit_repo_remote', repo_name=c.repo_name))) %>
49 <div class="field">
50 <div class="field">
50 <div class="label">
51 <div class="label">
51 <label for="clone_uri">${_('Remote uri')}:</label>
52 <label for="clone_uri">${_('Remote pull uri')}:</label>
52 </div>
53 </div>
53 <div class="input">
54 <div class="input">
54 %if c.rhodecode_db_repo.clone_uri:
55 %if c.rhodecode_db_repo.clone_uri:
@@ -83,14 +84,56 b''
83 ${h.hidden('repo_clone_uri_change', 'NEW')}
84 ${h.hidden('repo_clone_uri_change', 'NEW')}
84 %endif
85 %endif
85 <p id="alter_clone_uri_help_block" class="help-block">
86 <p id="alter_clone_uri_help_block" class="help-block">
86 <% pull_link = h.literal(h.link_to('remote sync', h.route_path('edit_repo_remote', repo_name=c.repo_name))) %>
87 ${_('http[s] url where from repository was imported. This field can used for doing {sync_link}.').format(sync_link=sync_link)|n} <br/>
87 ${_('http[s] url where from repository was imported, this field can used for doing {pull_link}.').format(pull_link=pull_link)|n} <br/>
88 ${_('This field is stored encrypted inside Database, a format of http://user:password@server.com/repo_name can be used and will be hidden from display.')}
89 </p>
90 </div>
91 </div>
92 <div class="field">
93 <div class="label">
94 <label for="push_uri">${_('Remote push uri')}:</label>
95 </div>
96 <div class="input">
97 %if c.rhodecode_db_repo.push_uri:
98 ## display, if we don't have any errors
99 % if not c.form['repo_push_uri'].error:
100 <div id="push_uri_hidden" class='text-as-placeholder'>
101 <span id="push_uri_hidden_value">${c.rhodecode_db_repo.push_uri_hidden}</span>
102 <span class="link" id="edit_push_uri"><i class="icon-edit"></i>${_('edit')}</span>
103 </div>
104 % endif
105
106 ## alter field
107 <div id="alter_push_uri" style="${'' if c.form['repo_push_uri'].error else 'display: none'}">
108 ${c.form['repo_push_uri'].render(css_class='medium', oid='push_uri', placeholder=_('enter new value, or leave empty to remove'))|n}
109 ${c.form.render_error(request, c.form['repo_push_uri'])|n}
110 % if c.form['repo_push_uri'].error:
111 ## we got error from form subit, means we modify the url
112 ${h.hidden('repo_push_uri_change', 'MOD')}
113 % else:
114 ${h.hidden('repo_push_uri_change', 'OLD')}
115 % endif
116
117 % if not c.form['repo_push_uri'].error:
118 <span class="link" id="cancel_edit_push_uri">${_('cancel')}</span>
119 % endif
120
121 </div>
122 %else:
123 ## not set yet, display form to set it
124 ${c.form['repo_push_uri'].render(css_class='medium', oid='push_uri')|n}
125 ${c.form.render_error(request, c.form['repo_push_uri'])|n}
126 ${h.hidden('repo_push_uri_change', 'NEW')}
127 %endif
128 <p id="alter_push_uri_help_block" class="help-block">
129 ${_('http[s] url to sync data back. This field can used for doing {sync_link}.').format(sync_link=sync_link)|n} <br/>
88 ${_('This field is stored encrypted inside Database, a format of http://user:password@server.com/repo_name can be used and will be hidden from display.')}
130 ${_('This field is stored encrypted inside Database, a format of http://user:password@server.com/repo_name can be used and will be hidden from display.')}
89 </p>
131 </p>
90 </div>
132 </div>
91 </div>
133 </div>
92 % else:
134 % else:
93 ${h.hidden('repo_clone_uri', '')}
135 ${h.hidden('repo_clone_uri', '')}
136 ${h.hidden('repo_push_uri', '')}
94 % endif
137 % endif
95
138
96 <div class="field">
139 <div class="field">
@@ -207,16 +250,11 b''
207 </div>
250 </div>
208
251
209 <script>
252 <script>
210 $(document).ready(function(){
253 $(document).ready(function () {
211 var cloneUrl = function() {
254 var cloneUrl = function (
212 var alterButton = $('#alter_clone_uri');
255 alterButton, editButton, cancelEditButton,
213 var editButton = $('#edit_clone_uri');
256 hiddenUrl, hiddenUrlValue, input, helpBlock, changedFlag) {
214 var cancelEditButton = $('#cancel_edit_clone_uri');
257
215 var hiddenUrl = $('#clone_uri_hidden');
216 var hiddenUrlValue = $('#clone_uri_hidden_value');
217 var input = $('#clone_uri');
218 var helpBlock = $('#alter_clone_uri_help_block');
219 var changedFlag = $('#repo_clone_uri_change');
220 var originalText = helpBlock.html();
258 var originalText = helpBlock.html();
221 var obfuscatedUrl = hiddenUrlValue.html();
259 var obfuscatedUrl = hiddenUrlValue.html();
222
260
@@ -255,7 +293,32 b''
255
293
256 setInitialState();
294 setInitialState();
257 initEvents();
295 initEvents();
258 }();
296 };
297
298
299 var alterButton = $('#alter_clone_uri');
300 var editButton = $('#edit_clone_uri');
301 var cancelEditButton = $('#cancel_edit_clone_uri');
302 var hiddenUrl = $('#clone_uri_hidden');
303 var hiddenUrlValue = $('#clone_uri_hidden_value');
304 var input = $('#clone_uri');
305 var helpBlock = $('#alter_clone_uri_help_block');
306 var changedFlag = $('#repo_clone_uri_change');
307 cloneUrl(
308 alterButton, editButton, cancelEditButton, hiddenUrl,
309 hiddenUrlValue, input, helpBlock, changedFlag);
310
311 var alterButton = $('#alter_push_uri');
312 var editButton = $('#edit_push_uri');
313 var cancelEditButton = $('#cancel_edit_push_uri');
314 var hiddenUrl = $('#push_uri_hidden');
315 var hiddenUrlValue = $('#push_uri_hidden_value');
316 var input = $('#push_uri');
317 var helpBlock = $('#alter_push_uri_help_block');
318 var changedFlag = $('#repo_push_uri_change');
319 cloneUrl(
320 alterButton, editButton, cancelEditButton, hiddenUrl,
321 hiddenUrlValue, input, helpBlock, changedFlag);
259
322
260 selectMyGroup = function(element) {
323 selectMyGroup = function(element) {
261 $("#repo_group").val($(element).data('personalGroupId')).trigger("change");
324 $("#repo_group").val($(element).data('personalGroupId')).trigger("change");
General Comments 0
You need to be logged in to leave comments. Login now