Skip to content

Ignoring merge commits with newline and extra text #454

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

Closed
wants to merge 2 commits into from

Conversation

dabit1gamma
Copy link

Description

If the merge commit has more characters after the new line it was not ignored by commitlint.

Motivation and Context

I had to do uncomfortable actions in order to avoid it.

Usage examples

For instance, this message was not be ignored:

Merge branch 'master' of https://github.com/xxx/xxx
#
# It looks like you may be committing a merge.
# If this is not correct, please remove the file
#	.git/MERGE_HEAD
# and try again.


# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 2 and 1 different commits each, respectively.
#   (use "git pull" to merge the remote branch into yours)
#
# All conflicts fixed but you are still merging.
#
# Changes to be committed:
#	modified:   config/locale/en.po
#	modified:   config/locale/es.po
#	modified:   config/locale/messages.pot
#

How Has This Been Tested?

I created a test

Types of changes

Bug fix (non-breaking change which fixes an issue)

@dabit1gamma
Copy link
Author

@byCedric Since I was lazy to clone the project in my computer I did it through the browser. But I did not create the commits in the right way so I deleted the pull request in order to create it again.

@byCedric
Copy link
Member

byCedric commented Oct 4, 2018

Nice @dabit1gamma, working litterally in the cloud 😄

I think I found it. Have you tried adding the m modifier (multiline) to the regex without changing it? I copied your tests and modified the regex using that modifier, it works flawlessly! 😄

c.match(
	/^((Merge pull request)|(Merge (.*?) into (.*?)|(Merge branch (.*?)))(?:\r?\n)*$)/m
),

@byCedric
Copy link
Member

byCedric commented Oct 4, 2018

I'm not 100% sure if the multiline modifer should apply to all regexes, but I'm sure @marionebl has something to say about that 😄

@dabit1gamma
Copy link
Author

@byCedric I tested your suggestion and it works as well. For me no matters what to use. BTW you have specific scopes for commits hehe again failing my PR...

@byCedric
Copy link
Member

byCedric commented Oct 4, 2018

Commitlint would be weird without linting its own commits 😉 you can use the subfolder name, so in your case is-ignored as scope.

@dabit1gamma
Copy link
Author

@byCedric haha totally agree. Well I have to leave the computer. Since it is not a great change maybe you can modify it in your computer and delete this PR?

@dabit1gamma dabit1gamma closed this Oct 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants