mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] runbot: allow to use base commit on new batch
This commit is contained in:
parent
2a7e76eec7
commit
39b049c575
@ -226,13 +226,13 @@ class Runbot(Controller):
|
|||||||
'/runbot/bundle/<model("runbot.bundle"):bundle>/force',
|
'/runbot/bundle/<model("runbot.bundle"):bundle>/force',
|
||||||
'/runbot/bundle/<model("runbot.bundle"):bundle>/force/<int:auto_rebase>',
|
'/runbot/bundle/<model("runbot.bundle"):bundle>/force/<int:auto_rebase>',
|
||||||
], type='http', auth="user", methods=['GET', 'POST'], csrf=False)
|
], type='http', auth="user", methods=['GET', 'POST'], csrf=False)
|
||||||
def force_bundle(self, bundle, auto_rebase=False, **_post):
|
def force_bundle(self, bundle, auto_rebase=False, use_base_commits=False,**_post):
|
||||||
if not request.env.user.has_group('runbot.group_runbot_advanced_user') and ':' not in bundle.name:
|
if not request.env.user.has_group('runbot.group_runbot_advanced_user') and ':' not in bundle.name:
|
||||||
raise Forbidden("Only users with a specific group can do that. Please contact runbot administrators")
|
raise Forbidden("Only users with a specific group can do that. Please contact runbot administrators")
|
||||||
_logger.info('user %s forcing bundle %s', request.env.user.name, bundle.name) # user must be able to read bundle
|
_logger.info('user %s forcing bundle %s', request.env.user.name, bundle.name) # user must be able to read bundle
|
||||||
batch = bundle.sudo()._force()
|
batch = bundle.sudo()._force()
|
||||||
batch._log('Batch forced by %s', request.env.user.name)
|
batch._log('Batch forced by %s', request.env.user.name)
|
||||||
batch._prepare(auto_rebase)
|
batch._prepare(auto_rebase=bool(auto_rebase), use_base_commits=bool(use_base_commits))
|
||||||
batch._process()
|
batch._process()
|
||||||
return werkzeug.utils.redirect('/runbot/batch/%s' % batch.id)
|
return werkzeug.utils.redirect('/runbot/batch/%s' % batch.id)
|
||||||
|
|
||||||
|
@ -174,8 +174,10 @@ class Batch(models.Model):
|
|||||||
build._github_status()
|
build._github_status()
|
||||||
return link_type, build
|
return link_type, build
|
||||||
|
|
||||||
def _prepare(self, auto_rebase=False):
|
def _prepare(self, auto_rebase=False, use_base_commits=False):
|
||||||
_logger.info('Preparing batch %s', self.id)
|
_logger.info('Preparing batch %s', self.id)
|
||||||
|
if use_base_commits:
|
||||||
|
self._warning('This batch will use base commits instead of bundle commits')
|
||||||
if not self.bundle_id.base_id:
|
if not self.bundle_id.base_id:
|
||||||
# in some case the base can be detected lately. If a bundle has no base, recompute the base before preparing
|
# in some case the base can be detected lately. If a bundle has no base, recompute the base before preparing
|
||||||
self.bundle_id._compute_base_id()
|
self.bundle_id._compute_base_id()
|
||||||
@ -359,6 +361,8 @@ class Batch(models.Model):
|
|||||||
commit_link.commit_id = commit_link.commit_id._rebase_on(commit_link.base_commit_id)
|
commit_link.commit_id = commit_link.commit_id._rebase_on(commit_link.base_commit_id)
|
||||||
commit_link_by_repos = {commit_link.commit_id.repo_id.id: commit_link for commit_link in self.commit_link_ids}
|
commit_link_by_repos = {commit_link.commit_id.repo_id.id: commit_link for commit_link in self.commit_link_ids}
|
||||||
base_commit_link_by_repos = {commit_link.commit_id.repo_id.id: commit_link for commit_link in self.base_reference_batch_id.commit_link_ids}
|
base_commit_link_by_repos = {commit_link.commit_id.repo_id.id: commit_link for commit_link in self.base_reference_batch_id.commit_link_ids}
|
||||||
|
if use_base_commits:
|
||||||
|
commit_link_by_repos = base_commit_link_by_repos
|
||||||
version_id = self.bundle_id.version_id.id
|
version_id = self.bundle_id.version_id.id
|
||||||
project_id = self.bundle_id.project_id.id
|
project_id = self.bundle_id.project_id.id
|
||||||
trigger_customs = {}
|
trigger_customs = {}
|
||||||
@ -376,6 +380,7 @@ class Batch(models.Model):
|
|||||||
config_data = dict(trigger.config_data or {}) | dict(trigger_custom.config_data or {})
|
config_data = dict(trigger.config_data or {}) | dict(trigger_custom.config_data or {})
|
||||||
trigger_commit_link_by_repos = commit_link_by_repos
|
trigger_commit_link_by_repos = commit_link_by_repos
|
||||||
if trigger_custom.use_base_commits and self.base_reference_batch_id:
|
if trigger_custom.use_base_commits and self.base_reference_batch_id:
|
||||||
|
self._warning(f'This batch will use base commits instead of bundle commits for trigger {trigger.name}')
|
||||||
trigger_commit_link_by_repos = base_commit_link_by_repos
|
trigger_commit_link_by_repos = base_commit_link_by_repos
|
||||||
commits_links = [trigger_commit_link_by_repos[repo.id].id for repo in trigger_repos]
|
commits_links = [trigger_commit_link_by_repos[repo.id].id for repo in trigger_repos]
|
||||||
params_value = {
|
params_value = {
|
||||||
|
@ -16,11 +16,14 @@
|
|||||||
<i class="fa fa-list"/>
|
<i class="fa fa-list"/>
|
||||||
</a>
|
</a>
|
||||||
<a groups="runbot.group_runbot_advanced_user" class="btn btn-default" t-attf-href="/runbot/bundle/{{bundle.id}}/force" title="Force A New Batch">
|
<a groups="runbot.group_runbot_advanced_user" class="btn btn-default" t-attf-href="/runbot/bundle/{{bundle.id}}/force" title="Force A New Batch">
|
||||||
<i class="fa fa-refresh"/>
|
<i class="fa fa-play"/>
|
||||||
</a>
|
</a>
|
||||||
<a t-if="bundle.env.user.has_group('runbot.group_runbot_advanced_user') or (bundle.env.user.has_group('runbot.group_user') and ':' in bundle.name)" class="btn btn-default" t-attf-href="/runbot/bundle/{{bundle.id}}/force/1" title="Force A New Batch with automatic rebase">
|
<a t-if="bundle.env.user.has_group('runbot.group_runbot_advanced_user') or (bundle.env.user.has_group('runbot.group_user') and ':' in bundle.name)" class="btn btn-default" t-attf-href="/runbot/bundle/{{bundle.id}}/force?auto_rebase=1" title="Force A New Batch with automatic rebase">
|
||||||
<i class="fa fa-fast-forward"/>
|
<i class="fa fa-fast-forward"/>
|
||||||
</a>
|
</a>
|
||||||
|
<a groups="runbot.group_runbot_advanced_user" class="btn btn-default" t-attf-href="/runbot/bundle/{{bundle.id}}/force?use_base_commits=1" title="Force A New Batch using base commits">
|
||||||
|
<i class="fa fa-fast-backward"/>
|
||||||
|
</a>
|
||||||
<t t-call="runbot.branch_copy_button">
|
<t t-call="runbot.branch_copy_button">
|
||||||
<t t-set="btn_size" t-value="'btn'"/>
|
<t t-set="btn_size" t-value="'btn'"/>
|
||||||
</t>
|
</t>
|
||||||
|
Loading…
Reference in New Issue
Block a user