com.mooltiverse.oss.nyx.configuration.presets.CommitMessageConventions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of main Show documentation
Show all versions of main Show documentation
com.mooltiverse.oss.nyx:main:3.0.7 null
/*
* Copyright 2020 Mooltiverse
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mooltiverse.oss.nyx.configuration.presets;
import com.mooltiverse.oss.nyx.entities.CommitMessageConvention;
/**
* This class provides reusable configuration chunks for commit message conventions.
*/
public class CommitMessageConventions {
/**
* The Conventional Commits configuration.
*/
public static final CommitMessageConvention CONVENTIONAL_COMMITS = new CommitMessageConvention() {
{
setExpression("(?m)^(?[a-zA-Z0-9_]+)(\\((?[a-z ]+)\\))?(!)?:( (?.+))$(?s).*");
getBumpExpressions().put("major", "(?s)(?m)^[a-zA-Z0-9_]+(\\([a-z ]+\\))?(!: .*|.*^(BREAKING( |-)CHANGE: )).*");
getBumpExpressions().put("minor", "(?s)(?m)^feat(!{0})(\\([a-z ]+\\))?: (?!.*^(BREAKING( |-)CHANGE: )).*");
getBumpExpressions().put("patch", "(?s)(?m)^fix(!{0})(\\([a-z ]+\\))?: (?!.*^(BREAKING( |-)CHANGE: )).*");
}
};
/**
* An unofficial extension for the Conventional Commits configuration
* which also parses the commit message body to detect which changes have occurred.
*
* This convention is useful in merge commits whose messages have been automatically generated listing all the commits
* that have been merged (i.e. when squashing) so the bump identifiers are scanned in the body, which may contain multiple
* significant rows, rather than just the first line.
*/
public static final CommitMessageConvention CONVENTIONAL_COMMITS_FOR_MERGE = new CommitMessageConvention() {
{
setExpression("(?[a-zA-Z0-9_]+)(!)?(\\((?[a-z ]+)\\))?:( (?.+))");
getBumpExpressions().put("major", "(?s)(?m)[a-zA-Z0-9_]+(!: .*|.*^(BREAKING( |-)CHANGE: )).*");
getBumpExpressions().put("minor", "(?s)(?m)feat(!{0})(\\([a-z ]+\\))?: (?!.*^(BREAKING( |-)CHANGE: )).*");
getBumpExpressions().put("patch", "(?s)(?m)fix(!{0})(\\([a-z ]+\\))?: (?!.*^(BREAKING( |-)CHANGE: )).*");
}
};
/**
* The gitmoji configuration.
*/
public static final CommitMessageConvention GITMOJI = new CommitMessageConvention() {
{
setExpression("(?m)^(?:[a-zA-Z0-9_]+:)( (?.+))?$(?s).*");
getBumpExpressions().put("major", "(?m)^:boom:(?s).*");
getBumpExpressions().put("minor", "(?m)^:sparkles:(?s).*");
getBumpExpressions().put("patch", "(?m)^:(zap|bug|ambulance|lipstick|lock|arrow_down|arrow_up|pushpin|chart_with_upwards_trend|heavy_plus_sign|heavy_minus_sign|wrench|globe_with_meridians|pencil2|rewind|package|alien|bento|wheelchair|speech_balloon|card_file_box|children_crossing|iphone|egg|alembic|mag|label|triangular_flag_on_post|goal_net|dizzy|wastebasket|passport_control|adhesive_bandage):(?s).*");
}
};
/**
* Default constructor is hidden on purpose.
*/
public CommitMessageConventions() {
super();
}
}