Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support excluding merge commits #41

Open
SamMousa opened this issue Feb 2, 2022 · 1 comment
Open

Support excluding merge commits #41

SamMousa opened this issue Feb 2, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@SamMousa
Copy link

SamMousa commented Feb 2, 2022

It would be great if we could easily (and maybe even by default) exclude merge commits from the requirement.

Quick merge

When doing a merge of 2 branches that use proper commit messages, the automated merge commit message doesn't really matter and shouldn't be subject to the strict structure of conventional commits.

Background/problem

I want to merge

Proposal/solution

Add an ignore pattern that matches the auto generated merge commit messages.

Alternatives

Write a merge: commit message for every merge.

@SamMousa SamMousa added the enhancement New feature or request label Feb 2, 2022
@gschafra
Copy link

gschafra commented Dec 5, 2022

@SamMousa Alternative solution would be implementing a custom Condition which checks if a merge is in progress. I've implemented following and it seems to work:

src/HookConditions/NotMerge.php:

<?php

	namespace App\HookConditions;

	use CaptainHook\App\Console\IO;
	use CaptainHook\App\Hook\Condition;
	use SebastianFeldmann\Git\Repository;

	class NotMerge implements Condition
	{

		/**
		 * @inheritDoc
		 */
		public function isTrue(IO $io, Repository $repository): bool
		{
			return !$repository->isMerging();
		}
	}

captainhook.json:

{
    "commit-msg": {
        "enabled": true,
        "actions": [
            {
                "action": "\\Ramsey\\CaptainHook\\ValidateConventionalCommit",
                "options": {
                    "config": {
                        "typeCase": null,
                        "types": [],
                        "scopeCase": null,
                        "scopeRequired": false,
                        "scopes": [],
                        "descriptionCase": null,
                        "descriptionEndMark": null,
                        "bodyRequired": false,
                        "bodyWrapWidth": null,
                        "requiredFooters": []
                    }
                },
                "conditions": [
                    {
                        "exec": "\\App\\HookConditions\\NotMerge"
                    }
                ]
            }
        ]
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants