Improves Fixup, Expand, Detail and Ignore Tags. Adds Priority Tag. A lot of git stuff below. [FIXUP] [[fixes]] sha = "2cfdcb10e2b2746ce7dc27b7864bd40c3005a638" newBody = ''' [EXPAND] [[messages]] messageBody = """ [IGNORE] checks = { compareBefore = "1.7-alpha-2" } # Only apply this if the commit being compared against is 1.7-alpha-2 or newer [IGNORE] [BREAKING] [DETAILS] details = [ \"Lots of QoL, Balance Changes and Bug Fixes from both GT 2.8 Update and Nomi Labs... Check your Recipes!\", \"**Please DO NOT revert any saves that have been loaded in this release to 1.7-alpha-2a or prior!**\", ] [DETAILS] [PRIORITY] priority = 20 [PRIORITY] """ [[messages]] messageBody = """ [COMBINE] commit = \"bd58b9072f45d647734ae66168cbd27bf9b2f220\" [COMBINE] [NO CATEGORY] """ [[messages]] messageBody = """ [FEATURE] [QOL] [DETAILS] details = [ \"Removes Anvil XP Scaling\", \"Custom Items, Blocks, and Multiblocks Improvements\", \"EIO Capacitor and Custom Capacitor Improvements\", \"Draconic Energy Core Improvements\", \"New ArchitectureCraft GUI for Sawbench & New Slopes (Comes from [GTNH's Fork](https://github.com/GTNewHorizons/ArchitectureCraft))\", \"Removes Bogo Feature in Bogo Sort\", \"Red Coal NBT Removal\", [\"Automatically Removed for all Red Coals Items, in AE2 Patterns and Elsewhere!\"], ] [DETAILS] """ [[messages]] messageBody = """ [QB] [DETAILS] detail = \"Genesis is Now Slowly Revealed\" [DETAILS] """ [[messages]] messageBody = """ [BUG] [DETAILS] details = [ \"Fixes NBT Recipe Problems\", \"Fixes Recycling Recipes\", \"Fixes HM Assembly Line Duplicate Recipe for UV Field Generator (#517)\", \"Fixes Some HM Assembly Line Recipes not having Research\", \"Fixes IV Quad/Nonuple Hatches & Buses being Uncraftable (#550)\", \"Fixes Missing ABS Recipes\", \"Fixes Language Override for Rhodium-Lumium Palladium\", \"Fixes Oxygen, Hydrogen and Nitrogen showing up as a Null Texture in JEI/HEI\", \"Fixes Multiblock Searching in JEI (#519)\", \"Removes Vanilla Ores from JEI\", \"Fixes Buckets showing up in JEI\", ] [DETAILS] [IGNORE] checks = { compareBefore = "1.7-alpha-2" } # Only apply this if the commit being compared against is 1.7-alpha-2 or newer [IGNORE] """ [[messages]] messageBody = """ [BUG] [DETAILS] details = [ \"Fixes NBT Recipe Problems\", \"Fixes Recycling Recipes\", \"Fixes Oxygen, Hydrogen and Nitrogen showing up as a Null Texture in JEI/HEI\", \"Fixes Multiblock Searching in JEI (#519)\", \"Removes Vanilla Ores from JEI\", \"Addresses Buckets showing up in JEI\", ] [DETAILS] [IGNORE] checks = { compareAfter = "1.7-alpha-2" } # Only apply this if the commit being compared against is 1.7-alpha-2 or older [IGNORE] """ [[messages]] messageBody = """ [BALANCING] [DETAILS] details = [ \"Added Cobaltite to the T3 Micro Miner\", \"Adds Recipe for Dragon Breath with High-Octane Gasoline (#629)\", \"Rebalance Processing Array Recipe (#501)\", \"Reduces Cost of Thermal Fluxbore (#392)\", [ \"Drill Head is now Cheaper, only requiring 5x Nomiquarters (25) instead of 5x Nomidollars (100) (Normal Mode)\", \"Fluxbore Head is now Cheaper, being Vanadium Steel Drill Head instead of Stainless Steel (Hard Mode)\", ], ] [DETAILS] """ [[messages]] messageBody = "[INTERNAL]" [EXPAND] ''' [[fixes]] sha = "bd58b9072f45d647734ae66168cbd27bf9b2f220" newTitle = "Update GT and Related Mods for 1.7" newBody = ''' [EXPAND] [[messages]] messageTitle = "Update GT to 2.8+, add Nomi Labs" messageBody = """ [BREAKING] [DETAILS] details = [ \"**Please DO NOT revert any saves that have been loaded in this release to 1.6.1a or prior!**\", \"**Lots of Recipes have been moved to the Assembly Line, and now require Assembly Line Research.**\", \"Adds Assembly Line Research\", \"Adds ME Hatches and Buses, for combining Multiblocks with AE Networks\", \"Adds Filtered Output Hatches\", \"Adds EU Multiblock Power Storage\", \"Adds Multiblock Transformer and Laser Power Transfer\", \"Adds Long Distance Pipes\", \"Creating Waypoints in the Prospector\", \"Fixing many Bugs\", \"And many more!\" ] [DETAILS] [PRIORITY] priority = 10 [PRIORITY] """ [[messages]] messageTitle = "Multiblock Changes" messageBody = """ [BREAKING] [DETAILS] details = [ \"Multiblocks accept a new **maximum** of 2 Energy Hatches.\", \"All Custom Multiblocks, such as Naquadah Reactors and Multiverse Projectors, now have **minimum casing requirements** and a **maintenance hatch**.\", \"Some Custom Multiblocks now have Distinct Mode\", \"All Custom Multiblocks now have custom Front Overlays\", \"Reworked & Improved Multiblock UIs\" ] [DETAILS] [PRIORITY] priority = 5 [PRIORITY] """ [EXPAND] ''' [FIXUP] [SKIP]
164 lines
5.3 KiB
TypeScript
164 lines
5.3 KiB
TypeScript
import { Category, Commit, Ignored, Parser, SubCategory } from "../../types/changelogTypes";
|
|
import {
|
|
categories,
|
|
combineKey,
|
|
defaultIndentation,
|
|
detailsKey,
|
|
expandKey,
|
|
ignoreKey,
|
|
modInfoKey,
|
|
noCategoryKey,
|
|
priorityKey,
|
|
} from "./definitions";
|
|
import { parseCombine, parseDetails, parseExpand, parseIgnore, parseModInfo, parsePriority } from "./specialParser";
|
|
import { getChangelog } from "../../util/util";
|
|
import ChangelogData from "./changelogData";
|
|
|
|
export default async function parseParser(data: ChangelogData, parser: Parser): Promise<void> {
|
|
const commits = await getChangelog(data.since, data.to, parser.dirs);
|
|
|
|
for (const commit of commits) {
|
|
if (data.shaList.has(commit.hash)) continue;
|
|
|
|
if (data.commitFixes.has(commit.hash)) {
|
|
const fixUpInfo = data.commitFixes.get(commit.hash);
|
|
if (fixUpInfo.newTitle) commit.message = fixUpInfo.newTitle;
|
|
if (fixUpInfo.newBody) {
|
|
switch (fixUpInfo.mode) {
|
|
case "REPLACE":
|
|
commit.body = fixUpInfo.newBody;
|
|
break;
|
|
case "ADDITION":
|
|
commit.body = commit.body.concat(`\n\n${fixUpInfo.newBody}`);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (parser.skipCallback(commit, commit.message, commit.body)) {
|
|
if (!parser.addSHACallback || parser.addSHACallback(commit, true)) data.shaList.add(commit.hash);
|
|
continue;
|
|
}
|
|
|
|
const parsed = await parser.itemCallback(parser, commit, commit.message, commit.body);
|
|
if (parsed instanceof Ignored) {
|
|
if (parsed.getCommitList() && parser.addCommitListCallback) {
|
|
if (parser.addCommitListCallback(commit, true)) data.commitList.push(commit);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
if (!parsed && parser.leftOverCallback) parser.leftOverCallback(commit, commit.message, commit.body, []);
|
|
if (!parser.addSHACallback || parser.addSHACallback(commit, parsed)) data.shaList.add(commit.hash);
|
|
|
|
if (parser.addCommitListCallback(commit, parsed)) data.commitList.push(commit);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Parses a commit body.
|
|
* @param commitMessage The commit message to put into the changelog.
|
|
* @param commitBody The commit body to parse with.
|
|
* @param commitObject The commit object.
|
|
* @param parser The parser object to use for parse expand/details.
|
|
* @return parsed Returns true if contains parsing keys, false if not.
|
|
*/
|
|
export async function parseCommitBody(
|
|
commitMessage: string,
|
|
commitBody: string,
|
|
commitObject: Commit,
|
|
parser: Parser,
|
|
): Promise<boolean | Ignored> {
|
|
if (commitBody.includes(expandKey)) {
|
|
await parseExpand(commitBody, commitObject, parser);
|
|
return true;
|
|
}
|
|
if (commitBody.includes(ignoreKey)) {
|
|
const ignore = await parseIgnore(commitBody, commitObject);
|
|
|
|
// Only return if ignore is not undefined
|
|
if (ignore) return ignore;
|
|
}
|
|
|
|
let newPriority = 0;
|
|
if (commitBody.includes(priorityKey)) {
|
|
const priority = await parsePriority(commitBody, commitObject);
|
|
|
|
// Only set if priority is not undefined or 0
|
|
if (priority) newPriority = priority;
|
|
}
|
|
// Copy commit if new priority (don't mess it up for other changelog messages when using expand)
|
|
if (commitObject.priority !== newPriority) {
|
|
commitObject = { ...commitObject };
|
|
commitObject.priority = newPriority;
|
|
}
|
|
|
|
if (commitBody.includes(modInfoKey)) await parseModInfo(commitBody, commitObject);
|
|
if (commitBody.includes(detailsKey)) {
|
|
await parseDetails(commitMessage, commitBody, commitObject, parser);
|
|
return true;
|
|
}
|
|
if (commitBody.includes(noCategoryKey)) {
|
|
return true;
|
|
}
|
|
if (commitBody.includes(combineKey)) {
|
|
await parseCombine(commitBody, commitObject);
|
|
return true;
|
|
}
|
|
return sortCommit(commitMessage, commitBody, commitObject);
|
|
}
|
|
|
|
/**
|
|
* Adds the (commit) message to its correct category. Does not parse special effect tags.
|
|
* @param message The message to add
|
|
* @param commitBody The body to use to sort
|
|
* @param commit The commit object to grab date, author and SHA from
|
|
* @param indentation The indentation of the message, if needed. Defaults to "".
|
|
* @return added If the commit message was added to a category
|
|
*/
|
|
function sortCommit(message: string, commitBody: string, commit: Commit, indentation = defaultIndentation): boolean {
|
|
const sortedCategories: Category[] = findCategories(commitBody);
|
|
if (sortedCategories.length === 0) return false;
|
|
|
|
sortedCategories.forEach((category) => {
|
|
const subCategory = findSubCategory(commitBody, category);
|
|
category.changelogSection.get(subCategory).push({
|
|
commitMessage: message,
|
|
commitObject: commit,
|
|
indentation: indentation,
|
|
});
|
|
});
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Finds the categories that a commit fits in.
|
|
* @param commitBody The commit body to sort with
|
|
* @return categoryList The categories that the commit belongs in. Return undefined if no category specified via keys.
|
|
*/
|
|
export function findCategories(commitBody: string): Category[] | undefined {
|
|
const sortedCategories: Category[] = [];
|
|
for (const category of categories) {
|
|
if (category.commitKey !== undefined) {
|
|
if (commitBody.includes(category.commitKey)) {
|
|
sortedCategories.push(category);
|
|
}
|
|
}
|
|
}
|
|
return sortedCategories;
|
|
}
|
|
|
|
/**
|
|
* Finds the correct Sub Category a commit should go in. Must be given the Category first!
|
|
*/
|
|
export function findSubCategory(commitBody: string, category: Category): SubCategory {
|
|
for (const subCategory of category.subCategories) {
|
|
if (subCategory.commitKey !== undefined) {
|
|
if (commitBody.includes(subCategory.commitKey)) {
|
|
return subCategory;
|
|
}
|
|
}
|
|
}
|
|
return category.defaultSubCategory;
|
|
}
|