All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.danielflower.mavenplugins.gitlog.renderers.JiraIssueLinkConverter Maven / Gradle / Ivy

Go to download

Generates a changelog based on commits to a git repository in text and HTML format showing the changes that are included in each version. A possible use of this is to include these changelogs when packaging your maven project so that you have an accurate list of commits that the current package includes.

The newest version!
package com.github.danielflower.mavenplugins.gitlog.renderers;

import org.apache.maven.plugin.logging.Log;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JiraIssueLinkConverter implements MessageConverter {

	private Pattern pattern;
	private final Log log;
	private final String urlPrefix;

	public JiraIssueLinkConverter(Log log, String urlPrefix, String jiraPattern) {
		this.log = log;
		// strip off trailing slash
		urlPrefix = urlPrefix.endsWith("/") ? urlPrefix.substring(0, urlPrefix.length() - 2) : urlPrefix;
		// strip off jira project code
		this.urlPrefix = urlPrefix.substring(0, urlPrefix.lastIndexOf("/") + 1);
		this.pattern = Pattern.compile(jiraPattern);
	}

	@Override
	public String formatCommitMessage(String original) {
		try {
			Matcher matcher = pattern.matcher(original);
				String result = matcher.replaceAll("$0");
				return result;
		} catch (Exception e) {
			// log, but don't let this small setback fail the build
			log.info("Unable to parse issue tracking URL in commit message: " + original, e);
		}
		return original;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy