Commit 2b6e5fdf authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '326997-master-to-main-extension' into 'master'

Update default initial branch name in the CI schema extension

See merge request gitlab-org/gitlab!63881
parents 726054b8 d2225b03
...@@ -14,9 +14,9 @@ export class CiSchemaExtension extends EditorLiteExtension { ...@@ -14,9 +14,9 @@ export class CiSchemaExtension extends EditorLiteExtension {
* @param {Object} opts * @param {Object} opts
* @param {String} opts.projectNamespace * @param {String} opts.projectNamespace
* @param {String} opts.projectPath * @param {String} opts.projectPath
* @param {String?} opts.ref - Current ref. Defaults to master * @param {String?} opts.ref - Current ref. Defaults to main
*/ */
registerCiSchema({ projectNamespace, projectPath, ref = 'master' } = {}) { registerCiSchema({ projectNamespace, projectPath, ref } = {}) {
const ciSchemaPath = Api.buildUrl(Api.projectFileSchemaPath) const ciSchemaPath = Api.buildUrl(Api.projectFileSchemaPath)
.replace(':namespace_path', projectNamespace) .replace(':namespace_path', projectNamespace)
.replace(':project_path', projectPath) .replace(':project_path', projectPath)
......
...@@ -10,7 +10,7 @@ export default { ...@@ -10,7 +10,7 @@ export default {
EditorLite, EditorLite,
}, },
mixins: [glFeatureFlagMixin()], mixins: [glFeatureFlagMixin()],
inject: ['ciConfigPath', 'projectPath', 'projectNamespace'], inject: ['ciConfigPath', 'projectPath', 'projectNamespace', 'defaultBranch'],
inheritAttrs: false, inheritAttrs: false,
data() { data() {
return { return {
...@@ -34,7 +34,7 @@ export default { ...@@ -34,7 +34,7 @@ export default {
editorInstance.registerCiSchema({ editorInstance.registerCiSchema({
projectPath: this.projectPath, projectPath: this.projectPath,
projectNamespace: this.projectNamespace, projectNamespace: this.projectNamespace,
ref: this.commitSha, ref: this.commitSha || this.defaultBranch,
}); });
} }
}, },
......
...@@ -4,6 +4,8 @@ import { EXTENSION_CI_SCHEMA_FILE_NAME_MATCH } from '~/editor/constants'; ...@@ -4,6 +4,8 @@ import { EXTENSION_CI_SCHEMA_FILE_NAME_MATCH } from '~/editor/constants';
import EditorLite from '~/editor/editor_lite'; import EditorLite from '~/editor/editor_lite';
import { CiSchemaExtension } from '~/editor/extensions/editor_ci_schema_ext'; import { CiSchemaExtension } from '~/editor/extensions/editor_ci_schema_ext';
const mockRef = 'AABBCCDD';
describe('~/editor/editor_ci_config_ext', () => { describe('~/editor/editor_ci_config_ext', () => {
const defaultBlobPath = '.gitlab-ci.yml'; const defaultBlobPath = '.gitlab-ci.yml';
...@@ -75,8 +77,6 @@ describe('~/editor/editor_ci_config_ext', () => { ...@@ -75,8 +77,6 @@ describe('~/editor/editor_ci_config_ext', () => {
}); });
it('with an schema uri that contains project and ref', () => { it('with an schema uri that contains project and ref', () => {
const mockRef = 'AABBCCDD';
instance.registerCiSchema({ instance.registerCiSchema({
projectNamespace: mockProjectNamespace, projectNamespace: mockProjectNamespace,
projectPath: mockProjectPath, projectPath: mockProjectPath,
...@@ -95,10 +95,11 @@ describe('~/editor/editor_ci_config_ext', () => { ...@@ -95,10 +95,11 @@ describe('~/editor/editor_ci_config_ext', () => {
instance.registerCiSchema({ instance.registerCiSchema({
projectNamespace: mockProjectNamespace, projectNamespace: mockProjectNamespace,
projectPath: mockProjectPath, projectPath: mockProjectPath,
ref: mockRef,
}); });
expect(getConfiguredYmlSchema()).toEqual({ expect(getConfiguredYmlSchema()).toEqual({
uri: `${TEST_HOST}/${mockProjectNamespace}/${mockProjectPath}/-/schema/master/${EXTENSION_CI_SCHEMA_FILE_NAME_MATCH}`, uri: `${TEST_HOST}/${mockProjectNamespace}/${mockProjectPath}/-/schema/${mockRef}/${EXTENSION_CI_SCHEMA_FILE_NAME_MATCH}`,
fileMatch: ['another-ci-filename.yml'], fileMatch: ['another-ci-filename.yml'],
}); });
}); });
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
mockCommitSha, mockCommitSha,
mockProjectPath, mockProjectPath,
mockProjectNamespace, mockProjectNamespace,
mockDefaultBranch,
} from '../../mock_data'; } from '../../mock_data';
describe('Pipeline Editor | Text editor component', () => { describe('Pipeline Editor | Text editor component', () => {
...@@ -38,6 +39,7 @@ describe('Pipeline Editor | Text editor component', () => { ...@@ -38,6 +39,7 @@ describe('Pipeline Editor | Text editor component', () => {
projectPath: mockProjectPath, projectPath: mockProjectPath,
projectNamespace: mockProjectNamespace, projectNamespace: mockProjectNamespace,
ciConfigPath: mockCiConfigPath, ciConfigPath: mockCiConfigPath,
defaultBranch: mockDefaultBranch,
glFeatures, glFeatures,
}, },
attrs: { attrs: {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment