Skip to content

Commit

Permalink
chore: 🔧 Fixing changelog condition to work properly in curseforge task
Browse files Browse the repository at this point in the history
  • Loading branch information
P3pp3rF1y committed Sep 16, 2024
1 parent f5f2a6b commit 475e3e8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ sonarqube {
}

task generateChangelog {
def changelog = new StringBuilder()
doLast {
def changelog = new StringBuilder()

// Function to remove characters with Unicode code points 129 or higher
def removeHighUnicodeChars = { text ->
text.codePoints()
Expand Down Expand Up @@ -222,7 +223,7 @@ task generateChangelog {

// Check if the latest commit is a merge commit
def parentCommits = "git rev-list --parents -n 1 ${latestCommitHash}".execute().text.split()
println("Parent commits: ${parentCommits}")
logger.info("Parent commits: ${parentCommits}")

def commitMessages = []
if (parentCommits.size() > 2) { // Merge commit has more than 2 parents
Expand All @@ -232,17 +233,16 @@ task generateChangelog {
"bash", "-c", "git log --pretty=format:%B ${firstParent}..${secondParent}"
]
commitMessages = gitLogCommand.execute().text.split('\n\n') // Split by two newlines for each commit
println("Merge commit, ran git log command: ${gitLogCommand.join(' ')} and got ${commitMessages}")
logger.info("Merge commit, ran git log command: ${gitLogCommand.join(' ')} and got ${commitMessages}")
} else {
// Single commit log
commitMessages = "git log -1 --pretty=%B".execute().text.split('\n\n')
// Split by two newlines for each commit
println("Single commit, ran git log command: git log -1 --pretty=%B and got ${commitMessages}");
logger.info("Single commit, ran git log command: git log -1 --pretty=%B and got ${commitMessages}");
}

def features = []
def fixes = []

commitMessages.each { commitMessage ->
commitMessage = removeHighUnicodeChars(commitMessage) // Remove high Unicode characters
commitMessage = removeDevSection(commitMessage) // Remove [DEV] section
Expand All @@ -265,9 +265,10 @@ task generateChangelog {
}

// Store the changelog in a project property or an environment variable
println(changelog.toString())
logger.info("Compiled changelog: " + changelog.toString())
project.ext.changelog = changelog.toString()
}
project.ext.changelog = changelog.toString()
project.ext.changelog = ""
}

task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) {
Expand Down

0 comments on commit 475e3e8

Please sign in to comment.