<commit_before>package bndtools.release;

import java.util.List;

import aQute.bnd.build.Project;
import aQute.bnd.build.ProjectBuilder;
import aQute.bnd.differ.Baseline;
import aQute.bnd.differ.DiffPluginImpl;
import aQute.bnd.osgi.Builder;
import aQute.bnd.osgi.Constants;
import aQute.bnd.osgi.Jar;

public class DiffHelper {

	public static Baseline createBaseline(Project project, String bsn) throws Exception {
		try (ProjectBuilder pb = project.getBuilder(null)) {
			List<Builder> builders = pb.getSubBuilders();
			for (Builder b : builders) {
				if (bsn.equals(b.getBsn())) {
					return createBaseline(b);
				}
			}
			return null;
		}
	}

	public static Baseline createBaseline(Builder builder) {

		try {

			if (builder instanceof ProjectBuilder) {

				ProjectBuilder projectBuilder = (ProjectBuilder) builder;

				Jar jar = null;
				Jar currentJar = null;

				try {
					jar = projectBuilder.build();

					currentJar = projectBuilder.getBaselineJar();
					if (currentJar == null) {
						currentJar = projectBuilder.getLastRevision();
					}
					if (currentJar == null) {
						currentJar = new Jar("."); //$NON-NLS-1$
					}
					DiffPluginImpl differ = new DiffPluginImpl();
					String diffignore = projectBuilder.getProperty(Constants.DIFFIGNORE);
					if (diffignore != null)
						differ.setIgnore(diffignore);

					Baseline baseline = new Baseline(projectBuilder, differ);

					baseline.baseline(jar, currentJar, null);
					return baseline;
				} finally {
					if (jar != null)
						jar.close();
					if (currentJar != null)
						currentJar.close();
				}
			}
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		return null;

	}

	public static String removeVersionQualifier(String version) {
		if (version == null) {
			return null;
		}<commit_msg>bndtools: Release baselining should process -diffpackages<commit_after>package bndtools.release;

import java.util.List;

import aQute.bnd.build.Project;
import aQute.bnd.build.ProjectBuilder;
import aQute.bnd.differ.Baseline;
import aQute.bnd.differ.DiffPluginImpl;
import aQute.bnd.osgi.Builder;
import aQute.bnd.osgi.Constants;
import aQute.bnd.osgi.Instructions;
import aQute.bnd.osgi.Jar;

public class DiffHelper {

	public static Baseline createBaseline(Project project, String bsn) throws Exception {
		try (ProjectBuilder pb = project.getBuilder(null)) {
			List<Builder> builders = pb.getSubBuilders();
			for (Builder b : builders) {
				if (bsn.equals(b.getBsn())) {
					return createBaseline(b);
				}
			}
			return null;
		}
	}

	public static Baseline createBaseline(Builder builder) {

		try {

			if (builder instanceof ProjectBuilder) {

				ProjectBuilder projectBuilder = (ProjectBuilder) builder;

				Jar jar = null;
				Jar currentJar = null;

				try {
					jar = projectBuilder.build();

					currentJar = projectBuilder.getBaselineJar();
					if (currentJar == null) {
						currentJar = projectBuilder.getLastRevision();
					}
					if (currentJar == null) {
						currentJar = new Jar("."); //$NON-NLS-1$
					}
					DiffPluginImpl differ = new DiffPluginImpl();
					String diffignore = projectBuilder.getProperty(Constants.DIFFIGNORE);
					if (diffignore != null)
						differ.setIgnore(diffignore);
					Instructions diffpackages = new Instructions(projectBuilder.getProperty(Constants.DIFFPACKAGES));

					Baseline baseline = new Baseline(projectBuilder, differ);

					baseline.baseline(jar, currentJar, diffpackages);
					return baseline;
				} finally {
					if (jar != null)
						jar.close();
					if (currentJar != null)
						currentJar.close();
				}
			}
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		return null;

	}

	public static String removeVersionQualifier(String version) {
		if (version == null) {
			return null;
		}
{'fraction_non_alphanumeric': 0.11119936457505956, 'fraction_numerical': 0.0015885623510722795, 'mean_word_length': 3.413551401869159, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2490864', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1177, 'n_words': 271}