mirror of
https://github.com/ansible/awx.git
synced 2026-05-10 02:47:36 -02:30
Adding the scm_track_submodules option which should fix the https://github.com/ansible/awx/issues/7846
Signed-off-by: mazhead <mazhead@gmail.com>
This commit is contained in:
@@ -1350,6 +1350,7 @@ class ProjectOptionsSerializer(BaseSerializer):
|
|||||||
'scm_branch',
|
'scm_branch',
|
||||||
'scm_refspec',
|
'scm_refspec',
|
||||||
'scm_clean',
|
'scm_clean',
|
||||||
|
'scm_track_submodules',
|
||||||
'scm_delete_on_update',
|
'scm_delete_on_update',
|
||||||
'credential',
|
'credential',
|
||||||
'timeout',
|
'timeout',
|
||||||
@@ -1497,7 +1498,7 @@ class ProjectSerializer(UnifiedJobTemplateSerializer, ProjectOptionsSerializer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if get_field_from_model_or_attrs('scm_type') == '':
|
if get_field_from_model_or_attrs('scm_type') == '':
|
||||||
for fd in ('scm_update_on_launch', 'scm_delete_on_update', 'scm_clean'):
|
for fd in ('scm_update_on_launch', 'scm_delete_on_update', 'scm_track_submodules', 'scm_clean'):
|
||||||
if get_field_from_model_or_attrs(fd):
|
if get_field_from_model_or_attrs(fd):
|
||||||
raise serializers.ValidationError({fd: _('Update options must be set to false for manual projects.')})
|
raise serializers.ValidationError({fd: _('Update options must be set to false for manual projects.')})
|
||||||
return super(ProjectSerializer, self).validate(attrs)
|
return super(ProjectSerializer, self).validate(attrs)
|
||||||
|
|||||||
37
awx/main/migrations/0136_scm_track_submodules.py
Normal file
37
awx/main/migrations/0136_scm_track_submodules.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Generated by Django 2.2.16 on 2021-02-02 14:41
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
<<<<<<< HEAD:awx/main/migrations/0136_scm_track_submodules.py
|
||||||
|
('main', '0135_schedule_sort_fallback_to_id'),
|
||||||
|
=======
|
||||||
|
('main', '0131_undo_org_polymorphic_ee'),
|
||||||
|
>>>>>>> Update and rename 0124_scm_track_submodules.py to 0132_scm_track_submodules.py:awx/main/migrations/0132_scm_track_submodules.py
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='Project',
|
||||||
|
name='scm_track_submodules',
|
||||||
|
field=models.BooleanField(help_text='Track submodule latest commit on specified branch.'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='ProjectUpdate',
|
||||||
|
name='scm_track_submodules',
|
||||||
|
field=models.BooleanField(help_text='Track submodule latest commit on specified branch.'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='project',
|
||||||
|
name='scm_track_submodules',
|
||||||
|
field=models.BooleanField(default=False, help_text='Track submodules latest commits on defined branch.'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='projectupdate',
|
||||||
|
name='scm_track_submodules',
|
||||||
|
field=models.BooleanField(default=False, help_text='Track submodules latest commits on defined branch.'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -115,6 +115,10 @@ class ProjectOptions(models.Model):
|
|||||||
default=False,
|
default=False,
|
||||||
help_text=_('Delete the project before syncing.'),
|
help_text=_('Delete the project before syncing.'),
|
||||||
)
|
)
|
||||||
|
scm_track_submodules = models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text=_('Track submodules latest commits on defined branch.'),
|
||||||
|
)
|
||||||
credential = models.ForeignKey(
|
credential = models.ForeignKey(
|
||||||
'Credential',
|
'Credential',
|
||||||
related_name='%(class)ss',
|
related_name='%(class)ss',
|
||||||
|
|||||||
@@ -2026,6 +2026,7 @@ class RunProjectUpdate(BaseTask):
|
|||||||
'scm_url': scm_url,
|
'scm_url': scm_url,
|
||||||
'scm_branch': scm_branch,
|
'scm_branch': scm_branch,
|
||||||
'scm_clean': project_update.scm_clean,
|
'scm_clean': project_update.scm_clean,
|
||||||
|
'scm_track_submodules': project_update.scm_track_submodules,
|
||||||
'roles_enabled': galaxy_creds_are_defined and settings.AWX_ROLES_ENABLED,
|
'roles_enabled': galaxy_creds_are_defined and settings.AWX_ROLES_ENABLED,
|
||||||
'collections_enabled': galaxy_creds_are_defined and settings.AWX_COLLECTIONS_ENABLED,
|
'collections_enabled': galaxy_creds_are_defined and settings.AWX_COLLECTIONS_ENABLED,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
# scm_password: password (only for svn/insights)
|
# scm_password: password (only for svn/insights)
|
||||||
# scm_accept_hostkey: true/false (only for git, set automatically)
|
# scm_accept_hostkey: true/false (only for git, set automatically)
|
||||||
# scm_refspec: a refspec to fetch in addition to obtaining version
|
# scm_refspec: a refspec to fetch in addition to obtaining version
|
||||||
|
# scm_track_submodules: true/false
|
||||||
# roles_enabled: Value of the global setting to enable roles downloading
|
# roles_enabled: Value of the global setting to enable roles downloading
|
||||||
# collections_enabled: Value of the global setting to enable collections downloading
|
# collections_enabled: Value of the global setting to enable collections downloading
|
||||||
# awx_version: Current running version of the awx or tower as a string
|
# awx_version: Current running version of the awx or tower as a string
|
||||||
@@ -36,6 +37,7 @@
|
|||||||
version: "{{scm_branch|quote}}"
|
version: "{{scm_branch|quote}}"
|
||||||
refspec: "{{scm_refspec|default(omit)}}"
|
refspec: "{{scm_refspec|default(omit)}}"
|
||||||
force: "{{scm_clean}}"
|
force: "{{scm_clean}}"
|
||||||
|
track_submodules: "{{scm_track_submodules|default(omit)}}"
|
||||||
accept_hostkey: "{{scm_accept_hostkey|default(omit)}}"
|
accept_hostkey: "{{scm_accept_hostkey|default(omit)}}"
|
||||||
register: git_result
|
register: git_result
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ function PromptProjectDetail({ i18n, resource }) {
|
|||||||
scm_branch,
|
scm_branch,
|
||||||
scm_clean,
|
scm_clean,
|
||||||
scm_delete_on_update,
|
scm_delete_on_update,
|
||||||
|
scm_track_submodules,
|
||||||
scm_refspec,
|
scm_refspec,
|
||||||
scm_type,
|
scm_type,
|
||||||
scm_update_on_launch,
|
scm_update_on_launch,
|
||||||
@@ -30,6 +31,7 @@ function PromptProjectDetail({ i18n, resource }) {
|
|||||||
if (
|
if (
|
||||||
scm_clean ||
|
scm_clean ||
|
||||||
scm_delete_on_update ||
|
scm_delete_on_update ||
|
||||||
|
scm_track_submodules ||
|
||||||
scm_update_on_launch ||
|
scm_update_on_launch ||
|
||||||
allow_override
|
allow_override
|
||||||
) {
|
) {
|
||||||
@@ -39,6 +41,11 @@ function PromptProjectDetail({ i18n, resource }) {
|
|||||||
{scm_delete_on_update && (
|
{scm_delete_on_update && (
|
||||||
<ListItem>{i18n._(t`Delete on Update`)}</ListItem>
|
<ListItem>{i18n._(t`Delete on Update`)}</ListItem>
|
||||||
)}
|
)}
|
||||||
|
{scm_track_submodules && (
|
||||||
|
<ListItem>
|
||||||
|
{i18n._(t`Track submodules latest commit on branch`)}
|
||||||
|
</ListItem>
|
||||||
|
)}
|
||||||
{scm_update_on_launch && (
|
{scm_update_on_launch && (
|
||||||
<ListItem>{i18n._(t`Update Revision on Launch`)}</ListItem>
|
<ListItem>{i18n._(t`Update Revision on Launch`)}</ListItem>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
"scm_refspec":"refs/",
|
"scm_refspec":"refs/",
|
||||||
"scm_clean":true,
|
"scm_clean":true,
|
||||||
"scm_delete_on_update":true,
|
"scm_delete_on_update":true,
|
||||||
|
"scm_track_submodules":false,
|
||||||
"credential":9,
|
"credential":9,
|
||||||
"timeout":0,
|
"timeout":0,
|
||||||
"scm_revision":"",
|
"scm_revision":"",
|
||||||
@@ -111,4 +112,4 @@
|
|||||||
"last_update_failed":false,
|
"last_update_failed":false,
|
||||||
"last_updated":"2020-03-11T20:18:14Z",
|
"last_updated":"2020-03-11T20:18:14Z",
|
||||||
"default_environment": 1
|
"default_environment": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ describe('<ProjectAdd />', () => {
|
|||||||
scm_type: 'git',
|
scm_type: 'git',
|
||||||
scm_url: 'https://foo.bar',
|
scm_url: 'https://foo.bar',
|
||||||
scm_clean: true,
|
scm_clean: true,
|
||||||
|
scm_track_submodules: false,
|
||||||
credential: 100,
|
credential: 100,
|
||||||
local_path: '',
|
local_path: '',
|
||||||
organization: { id: 2, name: 'Bar' },
|
organization: { id: 2, name: 'Bar' },
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ function ProjectDetail({ project, i18n }) {
|
|||||||
scm_branch,
|
scm_branch,
|
||||||
scm_clean,
|
scm_clean,
|
||||||
scm_delete_on_update,
|
scm_delete_on_update,
|
||||||
|
scm_track_submodules,
|
||||||
scm_refspec,
|
scm_refspec,
|
||||||
scm_type,
|
scm_type,
|
||||||
scm_update_on_launch,
|
scm_update_on_launch,
|
||||||
@@ -61,6 +62,7 @@ function ProjectDetail({ project, i18n }) {
|
|||||||
if (
|
if (
|
||||||
scm_clean ||
|
scm_clean ||
|
||||||
scm_delete_on_update ||
|
scm_delete_on_update ||
|
||||||
|
scm_track_submodules ||
|
||||||
scm_update_on_launch ||
|
scm_update_on_launch ||
|
||||||
allow_override
|
allow_override
|
||||||
) {
|
) {
|
||||||
@@ -70,6 +72,11 @@ function ProjectDetail({ project, i18n }) {
|
|||||||
{scm_delete_on_update && (
|
{scm_delete_on_update && (
|
||||||
<ListItem>{i18n._(t`Delete on Update`)}</ListItem>
|
<ListItem>{i18n._(t`Delete on Update`)}</ListItem>
|
||||||
)}
|
)}
|
||||||
|
{scm_track_submodules && (
|
||||||
|
<ListItem>
|
||||||
|
{i18n._(t`Track submodules latest commit on branch`)}
|
||||||
|
</ListItem>
|
||||||
|
)}
|
||||||
{scm_update_on_launch && (
|
{scm_update_on_launch && (
|
||||||
<ListItem>{i18n._(t`Update Revision on Launch`)}</ListItem>
|
<ListItem>{i18n._(t`Update Revision on Launch`)}</ListItem>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ describe('<ProjectDetail />', () => {
|
|||||||
scm_refspec: 'refs/remotes/*',
|
scm_refspec: 'refs/remotes/*',
|
||||||
scm_clean: true,
|
scm_clean: true,
|
||||||
scm_delete_on_update: true,
|
scm_delete_on_update: true,
|
||||||
|
scm_track_submodules: false,
|
||||||
credential: 100,
|
credential: 100,
|
||||||
status: 'successful',
|
status: 'successful',
|
||||||
organization: 10,
|
organization: 10,
|
||||||
@@ -141,6 +142,7 @@ describe('<ProjectDetail />', () => {
|
|||||||
scm_type: '',
|
scm_type: '',
|
||||||
scm_clean: false,
|
scm_clean: false,
|
||||||
scm_delete_on_update: false,
|
scm_delete_on_update: false,
|
||||||
|
scm_track_submodules: false,
|
||||||
scm_update_on_launch: false,
|
scm_update_on_launch: false,
|
||||||
allow_override: false,
|
allow_override: false,
|
||||||
created: '',
|
created: '',
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ describe('<ProjectEdit />', () => {
|
|||||||
scm_type: 'git',
|
scm_type: 'git',
|
||||||
scm_url: 'https://foo.bar',
|
scm_url: 'https://foo.bar',
|
||||||
scm_clean: true,
|
scm_clean: true,
|
||||||
|
scm_track_submodules: false,
|
||||||
credential: 100,
|
credential: 100,
|
||||||
local_path: 'bar',
|
local_path: 'bar',
|
||||||
organization: 2,
|
organization: 2,
|
||||||
|
|||||||
@@ -104,6 +104,7 @@
|
|||||||
"scm_refspec": "",
|
"scm_refspec": "",
|
||||||
"scm_clean": false,
|
"scm_clean": false,
|
||||||
"scm_delete_on_update": false,
|
"scm_delete_on_update": false,
|
||||||
|
"scm_track_submodules": false,
|
||||||
"credential": null,
|
"credential": null,
|
||||||
"timeout": 0,
|
"timeout": 0,
|
||||||
"scm_revision": "f5de82382e756b87143f3511c7c6c006d941830d",
|
"scm_revision": "f5de82382e756b87143f3511c7c6c006d941830d",
|
||||||
@@ -119,4 +120,4 @@
|
|||||||
"last_update_failed": false,
|
"last_update_failed": false,
|
||||||
"last_updated": "2019-09-30T18:06:34.713654Z",
|
"last_updated": "2019-09-30T18:06:34.713654Z",
|
||||||
"execution_environment": 1
|
"execution_environment": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ function ProjectFormFields({
|
|||||||
credential: '',
|
credential: '',
|
||||||
scm_clean: false,
|
scm_clean: false,
|
||||||
scm_delete_on_update: false,
|
scm_delete_on_update: false,
|
||||||
|
scm_track_submodules: false,
|
||||||
scm_update_on_launch: false,
|
scm_update_on_launch: false,
|
||||||
allow_override: false,
|
allow_override: false,
|
||||||
scm_update_cache_timeout: 0,
|
scm_update_cache_timeout: 0,
|
||||||
@@ -308,6 +309,7 @@ function ProjectForm({ i18n, project, submitError, ...props }) {
|
|||||||
credential: '',
|
credential: '',
|
||||||
scm_clean: false,
|
scm_clean: false,
|
||||||
scm_delete_on_update: false,
|
scm_delete_on_update: false,
|
||||||
|
scm_track_submodules: false,
|
||||||
scm_update_on_launch: false,
|
scm_update_on_launch: false,
|
||||||
allow_override: false,
|
allow_override: false,
|
||||||
scm_update_cache_timeout: 0,
|
scm_update_cache_timeout: 0,
|
||||||
@@ -365,6 +367,7 @@ function ProjectForm({ i18n, project, submitError, ...props }) {
|
|||||||
scm_branch: project.scm_branch || '',
|
scm_branch: project.scm_branch || '',
|
||||||
scm_clean: project.scm_clean || false,
|
scm_clean: project.scm_clean || false,
|
||||||
scm_delete_on_update: project.scm_delete_on_update || false,
|
scm_delete_on_update: project.scm_delete_on_update || false,
|
||||||
|
scm_track_submodules: project.scm_track_submodules || false,
|
||||||
scm_refspec: project.scm_refspec || '',
|
scm_refspec: project.scm_refspec || '',
|
||||||
scm_type:
|
scm_type:
|
||||||
project.scm_type === ''
|
project.scm_type === ''
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ describe('<ProjectForm />', () => {
|
|||||||
scm_type: 'git',
|
scm_type: 'git',
|
||||||
scm_url: 'https://foo.bar',
|
scm_url: 'https://foo.bar',
|
||||||
scm_clean: true,
|
scm_clean: true,
|
||||||
|
scm_track_submodules: false,
|
||||||
credential: 100,
|
credential: 100,
|
||||||
organization: 2,
|
organization: 2,
|
||||||
scm_update_on_launch: true,
|
scm_update_on_launch: true,
|
||||||
|
|||||||
@@ -84,6 +84,19 @@ export const ScmTypeOptions = withI18n()(
|
|||||||
of time required to complete an update.`
|
of time required to complete an update.`
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<CheckboxField
|
||||||
|
id="option-scm-track-submodules"
|
||||||
|
name="scm_track_submodules"
|
||||||
|
label={i18n._(t`Track submodules`)}
|
||||||
|
tooltip={i18n._(
|
||||||
|
t`if yes, submodules will track the latest commit on
|
||||||
|
their master branch (or other branch specified in
|
||||||
|
.gitmodules). If no, submodules will be kept at
|
||||||
|
the revision specified by the main project.
|
||||||
|
This is equivalent to specifying the --remote
|
||||||
|
flag to git submodule update.`
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<CheckboxField
|
<CheckboxField
|
||||||
id="option-scm-update-on-launch"
|
id="option-scm-update-on-launch"
|
||||||
name="scm_update_on_launch"
|
name="scm_update_on_launch"
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ export const Project = shape({
|
|||||||
scm_refspec: string,
|
scm_refspec: string,
|
||||||
scm_clean: bool,
|
scm_clean: bool,
|
||||||
scm_delete_on_update: bool,
|
scm_delete_on_update: bool,
|
||||||
|
scm_track_submodules: bool,
|
||||||
credential: number,
|
credential: number,
|
||||||
status: oneOf([
|
status: oneOf([
|
||||||
'new',
|
'new',
|
||||||
|
|||||||
@@ -78,6 +78,11 @@ options:
|
|||||||
- Remove the repository completely before updating.
|
- Remove the repository completely before updating.
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
scm_track_submodules:
|
||||||
|
description:
|
||||||
|
- Track submodules latest commit on specified branch.
|
||||||
|
type: bool
|
||||||
|
default: 'no'
|
||||||
scm_update_on_launch:
|
scm_update_on_launch:
|
||||||
description:
|
description:
|
||||||
- Before an update to the local repository before launching a job with this project.
|
- Before an update to the local repository before launching a job with this project.
|
||||||
@@ -245,6 +250,7 @@ def main():
|
|||||||
credential=dict(aliases=['scm_credential']),
|
credential=dict(aliases=['scm_credential']),
|
||||||
scm_clean=dict(type='bool', default=False),
|
scm_clean=dict(type='bool', default=False),
|
||||||
scm_delete_on_update=dict(type='bool', default=False),
|
scm_delete_on_update=dict(type='bool', default=False),
|
||||||
|
scm_track_submodules=dict(type='bool', default=False),
|
||||||
scm_update_on_launch=dict(type='bool', default=False),
|
scm_update_on_launch=dict(type='bool', default=False),
|
||||||
scm_update_cache_timeout=dict(type='int', default=0),
|
scm_update_cache_timeout=dict(type='int', default=0),
|
||||||
allow_override=dict(type='bool', aliases=['scm_allow_override']),
|
allow_override=dict(type='bool', aliases=['scm_allow_override']),
|
||||||
@@ -345,6 +351,7 @@ def main():
|
|||||||
'scm_refspec',
|
'scm_refspec',
|
||||||
'scm_clean',
|
'scm_clean',
|
||||||
'scm_delete_on_update',
|
'scm_delete_on_update',
|
||||||
|
"scm_track_submodules",
|
||||||
'timeout',
|
'timeout',
|
||||||
'scm_update_cache_timeout',
|
'scm_update_cache_timeout',
|
||||||
'custom_virtualenv',
|
'custom_virtualenv',
|
||||||
@@ -380,3 +387,4 @@ def main():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class Project(HasCopy, HasCreate, HasNotifications, UnifiedJobTemplate):
|
|||||||
'local_path',
|
'local_path',
|
||||||
'scm_clean',
|
'scm_clean',
|
||||||
'scm_delete_on_update',
|
'scm_delete_on_update',
|
||||||
|
'scm_track_submodules',
|
||||||
'scm_update_cache_timeout',
|
'scm_update_cache_timeout',
|
||||||
'scm_update_on_launch',
|
'scm_update_on_launch',
|
||||||
'scm_refspec',
|
'scm_refspec',
|
||||||
|
|||||||
Reference in New Issue
Block a user