From 85b219afb1ec385b801aa370e53629c1c355b8d6 Mon Sep 17 00:00:00 2001 From: Lexus Drumgold Date: Tue, 21 Nov 2023 02:51:54 -0500 Subject: [PATCH] feat(pull-requests): `ManagePullRequestsHandler` Signed-off-by: Lexus Drumgold --- .codecov.yml | 4 + .commitlintrc.cts | 4 +- .github/infrastructure.yml | 4 + .../__tests__/manage.command.spec-d.ts | 79 ++++++++++ .../commands/__tests__/manage.command.spec.ts | 84 ++++++++++ .../manage.handler.functional.spec.ts | 93 +++++++++++ .../__tests__/manage.handler.spec-d.ts | 15 ++ .../pull-requests/commands/index.ts | 7 + .../pull-requests/commands/manage.command.ts | 148 ++++++++++++++++++ .../pull-requests/commands/manage.handler.ts | 84 ++++++++++ .../enums/__tests__/merge-message.spec-d.ts | 26 +++ .../enums/__tests__/merge-title.spec-d.ts | 20 +++ .../enums/__tests__/squash-message.spec-d.ts | 26 +++ .../enums/__tests__/squash-title.spec-d.ts | 20 +++ src/subdomains/pull-requests/enums/index.ts | 9 ++ .../pull-requests/enums/merge-message.ts | 28 ++++ .../pull-requests/enums/merge-title.ts | 26 +++ .../pull-requests/enums/squash-message.ts | 28 ++++ .../pull-requests/enums/squash-title.ts | 24 +++ src/subdomains/pull-requests/index.ts | 7 + 20 files changed, 735 insertions(+), 1 deletion(-) create mode 100644 src/subdomains/pull-requests/commands/__tests__/manage.command.spec-d.ts create mode 100644 src/subdomains/pull-requests/commands/__tests__/manage.command.spec.ts create mode 100644 src/subdomains/pull-requests/commands/__tests__/manage.handler.functional.spec.ts create mode 100644 src/subdomains/pull-requests/commands/__tests__/manage.handler.spec-d.ts create mode 100644 src/subdomains/pull-requests/commands/index.ts create mode 100644 src/subdomains/pull-requests/commands/manage.command.ts create mode 100644 src/subdomains/pull-requests/commands/manage.handler.ts create mode 100644 src/subdomains/pull-requests/enums/__tests__/merge-message.spec-d.ts create mode 100644 src/subdomains/pull-requests/enums/__tests__/merge-title.spec-d.ts create mode 100644 src/subdomains/pull-requests/enums/__tests__/squash-message.spec-d.ts create mode 100644 src/subdomains/pull-requests/enums/__tests__/squash-title.spec-d.ts create mode 100644 src/subdomains/pull-requests/enums/index.ts create mode 100644 src/subdomains/pull-requests/enums/merge-message.ts create mode 100644 src/subdomains/pull-requests/enums/merge-title.ts create mode 100644 src/subdomains/pull-requests/enums/squash-message.ts create mode 100644 src/subdomains/pull-requests/enums/squash-title.ts create mode 100644 src/subdomains/pull-requests/index.ts diff --git a/.codecov.yml b/.codecov.yml index f3bfccb8..ef06b938 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -52,6 +52,10 @@ component_management: name: octokit paths: - src/subdomains/octokit/**/*.ts + - component_id: pull-requests + name: pull-requests + paths: + - src/subdomains/pull-requests/**/*.ts - component_id: queries name: queries paths: diff --git a/.commitlintrc.cts b/.commitlintrc.cts index d50d7b39..db5c50cb 100644 --- a/.commitlintrc.cts +++ b/.commitlintrc.cts @@ -28,13 +28,15 @@ const config: UserConfig = { 'inputs', 'labels', 'octokit', + 'pull-requests', 'queries', 'runner', 'security', 'teams', 'users' ]) - ] + ], + 'scope-max-length': [RuleConfigSeverity.Disabled] } } diff --git a/.github/infrastructure.yml b/.github/infrastructure.yml index 1e238145..7996f9da 100644 --- a/.github/infrastructure.yml +++ b/.github/infrastructure.yml @@ -53,8 +53,12 @@ branches: app: codecov - context: codecov/project/octokit app: codecov + - context: codecov/project/pull-requests + app: codecov - context: codecov/project/queries app: codecov + - context: codecov/project/security + app: codecov - context: codecov/project/teams app: codecov - context: codecov/project/users diff --git a/src/subdomains/pull-requests/commands/__tests__/manage.command.spec-d.ts b/src/subdomains/pull-requests/commands/__tests__/manage.command.spec-d.ts new file mode 100644 index 00000000..7767715f --- /dev/null +++ b/src/subdomains/pull-requests/commands/__tests__/manage.command.spec-d.ts @@ -0,0 +1,79 @@ +/** + * @file Type Tests - ManagePullRequestsCommand + * @module pull-requests/commands/tests/unit-d/ManagePullRequestsCommand + */ + +import type { + MergeMessage, + MergeTitle, + SquashMessage, + SquashTitle +} from '#src/pull-requests/enums' +import type { Nilable, ReadonlyKeys } from '@flex-development/tutils' +import type TestSubject from '../manage.command' + +describe('unit-d:pull-requests/commands/ManagePullRequestsCommand', () => { + it('should have all readonly keys', () => { + expectTypeOf().toEqualTypeOf>() + }) + + it('should match [auto_merge?: Nilable]', () => { + expectTypeOf() + .toHaveProperty('auto_merge') + .toEqualTypeOf>() + }) + + it('should match [delete_branch_on_merge?: Nilable]', () => { + expectTypeOf() + .toHaveProperty('delete_branch_on_merge') + .toEqualTypeOf>() + }) + + it('should match [merge?: Nilable]', () => { + expectTypeOf() + .toHaveProperty('merge') + .toEqualTypeOf>() + }) + + it('should match [merge_message?: Nilable]', () => { + expectTypeOf() + .toHaveProperty('merge_message') + .toEqualTypeOf>() + }) + + it('should match [merge_title?: Nilable]', () => { + expectTypeOf() + .toHaveProperty('merge_title') + .toEqualTypeOf>() + }) + + it('should match [rebase?: Nilable]', () => { + expectTypeOf() + .toHaveProperty('rebase') + .toEqualTypeOf>() + }) + + it('should match [squash?: Nilable]', () => { + expectTypeOf() + .toHaveProperty('squash') + .toEqualTypeOf>() + }) + + it('should match [squash_message?: Nilable]', () => { + expectTypeOf() + .toHaveProperty('squash_message') + .toEqualTypeOf>() + }) + + it('should match [squash_title?: Nilable]', () => { + expectTypeOf() + .toHaveProperty('squash_title') + .toEqualTypeOf>() + }) + + it('should match [update_branch?: Nilable]', () => { + expectTypeOf() + .toHaveProperty('update_branch') + .toEqualTypeOf>() + }) +}) diff --git a/src/subdomains/pull-requests/commands/__tests__/manage.command.spec.ts b/src/subdomains/pull-requests/commands/__tests__/manage.command.spec.ts new file mode 100644 index 00000000..b8fa2368 --- /dev/null +++ b/src/subdomains/pull-requests/commands/__tests__/manage.command.spec.ts @@ -0,0 +1,84 @@ +/** + * @file Unit Tests - ManagePullRequestsCommand + * @module pull-requests/commands/tests/unit/ManagePullRequestsCommand + */ + +import { + MergeMessage, + MergeTitle, + SquashMessage, + SquashTitle +} from '#src/pull-requests/enums' +import TestSubject from '../manage.command' + +describe('unit:pull-requests/commands/ManagePullRequestsCommand', () => { + describe('constructor', () => { + let auto_merge: boolean + let delete_branch_on_merge: boolean + let merge: boolean + let merge_message: MergeMessage + let merge_title: MergeTitle + let rebase: boolean + let squash: boolean + let squash_message: SquashMessage + let squash_title: SquashTitle + let subject: TestSubject + let update_branch: boolean + + beforeAll(() => { + subject = new TestSubject({ + auto_merge: auto_merge = true, + delete_branch_on_merge: delete_branch_on_merge = true, + merge: merge = false, + merge_message: merge_message = MergeMessage.BLANK, + merge_title: merge_title = MergeTitle.PR_TITLE, + rebase: rebase = true, + squash: squash = true, + squash_message: squash_message = SquashMessage.BLANK, + squash_title: squash_title = SquashTitle.PR_TITLE, + update_branch: update_branch = true + }) + }) + + it('should set #auto_merge', () => { + expect(subject).to.have.property('auto_merge', auto_merge) + }) + + it('should set #delete_branch_on_merge', () => { + expect(subject) + .to.have.property('delete_branch_on_merge', delete_branch_on_merge) + }) + + it('should set #merge', () => { + expect(subject).to.have.property('merge', merge) + }) + + it('should set #merge_message', () => { + expect(subject).to.have.property('merge_message', merge_message) + }) + + it('should set #merge_title', () => { + expect(subject).to.have.property('merge_title', merge_title) + }) + + it('should set #rebase', () => { + expect(subject).to.have.property('rebase', rebase) + }) + + it('should set #squash', () => { + expect(subject).to.have.property('squash', squash) + }) + + it('should set #squash_message', () => { + expect(subject).to.have.property('squash_message', squash_message) + }) + + it('should set #squash_title', () => { + expect(subject).to.have.property('squash_title', squash_title) + }) + + it('should set #update_branch', () => { + expect(subject).to.have.property('update_branch', update_branch) + }) + }) +}) diff --git a/src/subdomains/pull-requests/commands/__tests__/manage.handler.functional.spec.ts b/src/subdomains/pull-requests/commands/__tests__/manage.handler.functional.spec.ts new file mode 100644 index 00000000..5195647c --- /dev/null +++ b/src/subdomains/pull-requests/commands/__tests__/manage.handler.functional.spec.ts @@ -0,0 +1,93 @@ +/** + * @file Functional Tests - ManagePullRequestsHandler + * @module pull-requests/commands/tests/functional/ManagePullRequestsHandler + */ + +import data from '#fixtures/api.github.com/graphql.json' assert { type: 'json' } +import OctokitProvider from '#fixtures/octokit.provider.fixture' +import type { Config } from '#src/config' +import { Octokit } from '#src/octokit' +import { + MergeMessage, + MergeTitle, + SquashMessage, + SquashTitle +} from '#src/pull-requests/enums' +import { ConfigService } from '@nestjs/config' +import { CqrsModule } from '@nestjs/cqrs' +import { Test, type TestingModule } from '@nestjs/testing' +import ManagePullRequestsCommand from '../manage.command' +import TestSubject from '../manage.handler' + +describe('functional:pull-requests/commands/ManagePullRequestsHandler', () => { + let config: ConfigService + let octokit: Octokit + let ref: TestingModule + let subject: TestSubject + + beforeAll(async () => { + ref = await (await Test.createTestingModule({ + imports: [CqrsModule], + providers: [ + OctokitProvider, + TestSubject, + { + provide: ConfigService, + useValue: new ConfigService({ + owner: data.data.organization.login, + repo: data.data.repository.name + }) + } + ] + }).compile()).init() + + config = ref.get(ConfigService) + octokit = ref.get(Octokit) + subject = ref.get(TestSubject) + }) + + describe('#execute', () => { + let command: ManagePullRequestsCommand + + beforeAll(() => { + command = new ManagePullRequestsCommand({ + auto_merge: true, + delete_branch_on_merge: true, + merge: false, + merge_message: MergeMessage.BLANK, + merge_title: MergeTitle.PR_TITLE, + rebase: true, + squash: true, + squash_message: SquashMessage.BLANK, + squash_title: SquashTitle.PR_TITLE, + update_branch: true + }) + }) + + beforeEach(() => { + vi.spyOn(octokit.rest.repos, 'update') + }) + + it('should manage pull request settings', async () => { + // Act + await subject.execute(command) + + // Expect + expect(octokit.rest.repos.update).toHaveBeenCalledOnce() + expect(octokit.rest.repos.update).toHaveBeenCalledWith({ + allow_auto_merge: command.auto_merge, + allow_merge_commit: command.merge, + allow_rebase_merge: command.rebase, + allow_squash_merge: command.squash, + allow_update_branch: command.update_branch, + delete_branch_on_merge: command.delete_branch_on_merge, + merge_message: command.merge_message, + merge_title: command.merge_title, + owner: config.get('owner'), + repo: config.get('repo'), + squash_merge_message: command.squash_message, + squash_merge_title: command.squash_title + }) + }) + }) +}) diff --git a/src/subdomains/pull-requests/commands/__tests__/manage.handler.spec-d.ts b/src/subdomains/pull-requests/commands/__tests__/manage.handler.spec-d.ts new file mode 100644 index 00000000..54dd184b --- /dev/null +++ b/src/subdomains/pull-requests/commands/__tests__/manage.handler.spec-d.ts @@ -0,0 +1,15 @@ +/** + * @file Type Tests - ManagePullRequestsHandler + * @module pull-requests/commands/tests/unit-d/ManagePullRequestsHandler + */ + +import type { ICommandHandler } from '@nestjs/cqrs' +import type ManagePullRequestsCommand from '../manage.command' +import type TestSubject from '../manage.handler' + +describe('unit-d:pull-requests/commands/ManagePullRequestsHandler', () => { + it('should implement ICommandHandler', () => { + expectTypeOf() + .toMatchTypeOf>() + }) +}) diff --git a/src/subdomains/pull-requests/commands/index.ts b/src/subdomains/pull-requests/commands/index.ts new file mode 100644 index 00000000..fca98daf --- /dev/null +++ b/src/subdomains/pull-requests/commands/index.ts @@ -0,0 +1,7 @@ +/** + * @file Entry Point - Commands + * @module repostructure/pull-requests/commands + */ + +export { default as ManagePullRequestsCommand } from './manage.command' +export { default as ManagePullRequestsHandler } from './manage.handler' diff --git a/src/subdomains/pull-requests/commands/manage.command.ts b/src/subdomains/pull-requests/commands/manage.command.ts new file mode 100644 index 00000000..f1cee17d --- /dev/null +++ b/src/subdomains/pull-requests/commands/manage.command.ts @@ -0,0 +1,148 @@ +/** + * @file Commands - ManagePullRequestsCommand + * @module repostructure/pull-requests/commands/ManagePullRequestsCommand + */ + +import type { + MergeMessage, + MergeTitle, + SquashMessage, + SquashTitle +} from '#src/pull-requests/enums' +import type { Nilable } from '@flex-development/tutils' + +/** + * Pull request settings management command. + * + * @class + */ +class ManagePullRequestsCommand { + /** + * Auto-merge enabled? + * + * @public + * @readonly + * @instance + * @member {Nilable?} auto_merge + */ + public readonly auto_merge?: Nilable + + /** + * Automatically delete head branches when pull requests are merged. + * + * @public + * @readonly + * @instance + * @member {Nilable?} delete_branch_on_merge + */ + public readonly delete_branch_on_merge?: Nilable + + /** + * Allow merging pull requests with merge commits. + * + * @public + * @readonly + * @instance + * @member {Nilable?} merge + */ + public readonly merge?: Nilable + + /** + * Default value for merge commit messages. + * + * @see {@linkcode MergeMessage} + * + * @public + * @readonly + * @instance + * @member {Nilable?} merge_message + */ + public readonly merge_message?: Nilable + + /** + * Default value for merge commit titles. + * + * @see {@linkcode MergeTitle} + * + * @public + * @readonly + * @instance + * @member {Nilable?} merge_title + */ + public readonly merge_title?: Nilable + + /** + * Allow rebase-merging pull requests. + * + * @public + * @readonly + * @instance + * @member {Nilable?} rebase + */ + public readonly rebase?: Nilable + + /** + * Allow squash-merging pull requests. + * + * @public + * @readonly + * @instance + * @member {Nilable?} squash + */ + public readonly squash?: Nilable + + /** + * Default value for squash commit messages. + * + * @see {@linkcode SquashMessage} + * + * @public + * @readonly + * @instance + * @member {Nilable?} squash_message + */ + public readonly squash_message?: Nilable + + /** + * Default value for squash commit titles. + * + * @see {@linkcode SquashTitle} + * + * @public + * @readonly + * @instance + * @member {Nilable?} squash_title + */ + public readonly squash_title?: Nilable + + /** + * Always allow a pull request head branch that is behind its base branch to + * be updated even if not required to be up to date before merging. + * + * @public + * @readonly + * @instance + * @member {Nilable?} update_branch + */ + public readonly update_branch?: Nilable + + /** + * Create a new pull request settings management command. + * + * @param {ManagePullRequestsCommand} params - Command parameters + */ + constructor(params: ManagePullRequestsCommand) { + this.auto_merge = params.auto_merge + this.delete_branch_on_merge = params.delete_branch_on_merge + this.merge = params.merge + this.merge_message = params.merge_message + this.merge_title = params.merge_title + this.rebase = params.rebase + this.squash = params.squash + this.squash_message = params.squash_message + this.squash_title = params.squash_title + this.update_branch = params.update_branch + } +} + +export default ManagePullRequestsCommand diff --git a/src/subdomains/pull-requests/commands/manage.handler.ts b/src/subdomains/pull-requests/commands/manage.handler.ts new file mode 100644 index 00000000..6f665259 --- /dev/null +++ b/src/subdomains/pull-requests/commands/manage.handler.ts @@ -0,0 +1,84 @@ +/** + * @file Commands - ManagePullRequestsHandler + * @module repostructure/pull-requests/commands/ManagePullRequestsHandler + */ + +import type { Config } from '#src/config' +import { Octokit } from '#src/octokit' +import { isNIL, shake, type NIL } from '@flex-development/tutils' +import { ConfigService } from '@nestjs/config' +import { CommandHandler, type ICommandHandler } from '@nestjs/cqrs' +import type { Endpoints } from '@octokit/types' +import ManagePullRequestsCommand from './manage.command' + +/** + * Pull request settings management command handler. + * + * @see {@linkcode ManagePullRequestsCommand} + * + * @class + * @extends {ICommandHandler} + */ +@CommandHandler(ManagePullRequestsCommand) +class ManagePullRequestsHandler + implements ICommandHandler { + /** + * Create a new pull request settings management command handler. + * + * @see {@linkcode ConfigService} + * @see {@linkcode Config} + * @see {@linkcode Octokit} + * + * @param {Octokit} octokit - Hydrated octokit client + * @param {ConfigService} config - Infrastructure config service + */ + constructor( + protected readonly octokit: Octokit, + protected readonly config: ConfigService + ) {} + + /** + * Execute a pull request settings management command. + * + * @see {@linkcode ManagePullRequestsCommand} + * + * @public + * @async + * + * @param {ManagePullRequestsCommand} command - Command to execute + * @return {Promise} Nothing when complete + */ + public async execute(command: ManagePullRequestsCommand): Promise { + type Params = Endpoints['PATCH /repos/{owner}/{repo}']['parameters'] + + const { + auto_merge, + delete_branch_on_merge, + merge, + merge_message, + merge_title, + rebase, + squash, + squash_message, + squash_title, + update_branch + } = shake(command, isNIL) + + return void await this.octokit.rest.repos.update({ + allow_auto_merge: auto_merge, + allow_merge_commit: merge, + allow_rebase_merge: rebase, + allow_squash_merge: squash, + allow_update_branch: update_branch, + delete_branch_on_merge, + merge_message, + merge_title, + owner: this.config.get('owner'), + repo: this.config.get('repo'), + squash_merge_message: squash_message, + squash_merge_title: squash_title + }) + } +} + +export default ManagePullRequestsHandler diff --git a/src/subdomains/pull-requests/enums/__tests__/merge-message.spec-d.ts b/src/subdomains/pull-requests/enums/__tests__/merge-message.spec-d.ts new file mode 100644 index 00000000..f1ded429 --- /dev/null +++ b/src/subdomains/pull-requests/enums/__tests__/merge-message.spec-d.ts @@ -0,0 +1,26 @@ +/** + * @file Type Tests - MergeMessage + * @module pull-requests/enums/tests/unit-d/MergeMessage + */ + +import type TestSubject from '../merge-message' + +describe('unit-d:pull-requests/enums/MergeMessage', () => { + it('should match [BLANK = "BLANK"]', () => { + expectTypeOf() + .toHaveProperty('BLANK') + .toMatchTypeOf<'BLANK'>() + }) + + it('should match [PR_BODY = "PR_BODY"]', () => { + expectTypeOf() + .toHaveProperty('PR_BODY') + .toMatchTypeOf<'PR_BODY'>() + }) + + it('should match [PR_TITLE = "PR_TITLE"]', () => { + expectTypeOf() + .toHaveProperty('PR_TITLE') + .toMatchTypeOf<'PR_TITLE'>() + }) +}) diff --git a/src/subdomains/pull-requests/enums/__tests__/merge-title.spec-d.ts b/src/subdomains/pull-requests/enums/__tests__/merge-title.spec-d.ts new file mode 100644 index 00000000..bf6fb112 --- /dev/null +++ b/src/subdomains/pull-requests/enums/__tests__/merge-title.spec-d.ts @@ -0,0 +1,20 @@ +/** + * @file Type Tests - MergeTitle + * @module pull-requests/enums/tests/unit-d/MergeTitle + */ + +import type TestSubject from '../merge-title' + +describe('unit-d:pull-requests/enums/MergeTitle', () => { + it('should match [MERGE_MESSAGE = "MERGE_MESSAGE"]', () => { + expectTypeOf() + .toHaveProperty('MERGE_MESSAGE') + .toMatchTypeOf<'MERGE_MESSAGE'>() + }) + + it('should match [PR_TITLE = "PR_TITLE"]', () => { + expectTypeOf() + .toHaveProperty('PR_TITLE') + .toMatchTypeOf<'PR_TITLE'>() + }) +}) diff --git a/src/subdomains/pull-requests/enums/__tests__/squash-message.spec-d.ts b/src/subdomains/pull-requests/enums/__tests__/squash-message.spec-d.ts new file mode 100644 index 00000000..c74e4348 --- /dev/null +++ b/src/subdomains/pull-requests/enums/__tests__/squash-message.spec-d.ts @@ -0,0 +1,26 @@ +/** + * @file Type Tests - SquashMessage + * @module pull-requests/enums/tests/unit-d/SquashMessage + */ + +import type TestSubject from '../squash-message' + +describe('unit-d:pull-requests/enums/SquashMessage', () => { + it('should match [BLANK = "BLANK"]', () => { + expectTypeOf() + .toHaveProperty('BLANK') + .toMatchTypeOf<'BLANK'>() + }) + + it('should match [COMMIT_MESSAGES = "COMMIT_MESSAGES"]', () => { + expectTypeOf() + .toHaveProperty('COMMIT_MESSAGES') + .toMatchTypeOf<'COMMIT_MESSAGES'>() + }) + + it('should match [PR_BODY = "PR_BODY"]', () => { + expectTypeOf() + .toHaveProperty('PR_BODY') + .toMatchTypeOf<'PR_BODY'>() + }) +}) diff --git a/src/subdomains/pull-requests/enums/__tests__/squash-title.spec-d.ts b/src/subdomains/pull-requests/enums/__tests__/squash-title.spec-d.ts new file mode 100644 index 00000000..4c6434a5 --- /dev/null +++ b/src/subdomains/pull-requests/enums/__tests__/squash-title.spec-d.ts @@ -0,0 +1,20 @@ +/** + * @file Type Tests - SquashTitle + * @module pull-requests/enums/tests/unit-d/SquashTitle + */ + +import type TestSubject from '../squash-title' + +describe('unit-d:pull-requests/enums/SquashTitle', () => { + it('should match [COMMIT_OR_PR_TITLE = "COMMIT_OR_PR_TITLE"]', () => { + expectTypeOf() + .toHaveProperty('COMMIT_OR_PR_TITLE') + .toMatchTypeOf<'COMMIT_OR_PR_TITLE'>() + }) + + it('should match [PR_TITLE = "PR_TITLE"]', () => { + expectTypeOf() + .toHaveProperty('PR_TITLE') + .toMatchTypeOf<'PR_TITLE'>() + }) +}) diff --git a/src/subdomains/pull-requests/enums/index.ts b/src/subdomains/pull-requests/enums/index.ts new file mode 100644 index 00000000..354e46fd --- /dev/null +++ b/src/subdomains/pull-requests/enums/index.ts @@ -0,0 +1,9 @@ +/** + * @file Entry Point - Enums + * @module repostructure/pull-requests/enums + */ + +export { default as MergeMessage } from './merge-message' +export { default as MergeTitle } from './merge-title' +export { default as SquashMessage } from './squash-message' +export { default as SquashTitle } from './squash-title' diff --git a/src/subdomains/pull-requests/enums/merge-message.ts b/src/subdomains/pull-requests/enums/merge-message.ts new file mode 100644 index 00000000..6b325491 --- /dev/null +++ b/src/subdomains/pull-requests/enums/merge-message.ts @@ -0,0 +1,28 @@ +/** + * @file Enums - MergeMessage + * @module repostructure/pull-requests/enums/MergeMessage + */ + +/** + * Default values for merge commit messages. + * + * @enum {Uppercase} + */ +enum MergeMessage { + /** + * Default to blank commit message. + */ + BLANK = 'BLANK', + + /** + * Default to pull request body. + */ + PR_BODY = 'PR_BODY', + + /** + * Default to pull request title. + */ + PR_TITLE = 'PR_TITLE' +} + +export default MergeMessage diff --git a/src/subdomains/pull-requests/enums/merge-title.ts b/src/subdomains/pull-requests/enums/merge-title.ts new file mode 100644 index 00000000..49834874 --- /dev/null +++ b/src/subdomains/pull-requests/enums/merge-title.ts @@ -0,0 +1,26 @@ +/** + * @file Enums - MergeTitle + * @module repostructure/pull-requests/enums/MergeTitle + */ + +/** + * Default values for merge commit titles. + * + * @enum {Uppercase} + */ +enum MergeTitle { + /** + * Default to classic title. + * + * @example + * 'Merge pull request #123 from branch-name' + */ + MERGE_MESSAGE = 'MERGE_MESSAGE', + + /** + * Default to pull request title. + */ + PR_TITLE = 'PR_TITLE' +} + +export default MergeTitle diff --git a/src/subdomains/pull-requests/enums/squash-message.ts b/src/subdomains/pull-requests/enums/squash-message.ts new file mode 100644 index 00000000..088a56f5 --- /dev/null +++ b/src/subdomains/pull-requests/enums/squash-message.ts @@ -0,0 +1,28 @@ +/** + * @file Enums - SquashMessage + * @module repostructure/pull-requests/enums/SquashMessage + */ + +/** + * Default values for squash commit messages. + * + * @enum {Uppercase} + */ +enum SquashMessage { + /** + * Default to blank commit message. + */ + BLANK = 'BLANK', + + /** + * Default to branch's commit messages. + */ + COMMIT_MESSAGES = 'COMMIT_MESSAGES', + + /** + * Default to pull request body. + */ + PR_BODY = 'PR_BODY' +} + +export default SquashMessage diff --git a/src/subdomains/pull-requests/enums/squash-title.ts b/src/subdomains/pull-requests/enums/squash-title.ts new file mode 100644 index 00000000..c994b01d --- /dev/null +++ b/src/subdomains/pull-requests/enums/squash-title.ts @@ -0,0 +1,24 @@ +/** + * @file Enums - SquashTitle + * @module repostructure/pull-requests/enums/SquashTitle + */ + +/** + * Default values for squash commit titles. + * + * @enum {Uppercase} + */ +enum SquashTitle { + /** + * Default to commit title (if only one commit) or pull request title (if more + * than one commit). + */ + COMMIT_OR_PR_TITLE = 'COMMIT_OR_PR_TITLE', + + /** + * Default to pull request title. + */ + PR_TITLE = 'PR_TITLE' +} + +export default SquashTitle diff --git a/src/subdomains/pull-requests/index.ts b/src/subdomains/pull-requests/index.ts new file mode 100644 index 00000000..ef1a7ecd --- /dev/null +++ b/src/subdomains/pull-requests/index.ts @@ -0,0 +1,7 @@ +/** + * @file Entry Point - pull-requests + * @module repostructure/pull-requests + */ + +export * from './commands' +export * from './enums'