Jenkins 子模块提示修复

This commit is contained in:
zhang hongbo 2026-03-25 15:18:44 +08:00
parent ce8ae37c30
commit 221e312447

View File

@ -159,13 +159,24 @@ def call(Map config)
def submoduleSections = []
submoduleLines.each { rawLine ->
def line = rawLine.replace('\r', '')
def matcher = (line =~ /^(.)([0-9a-f]{40})\s+([^\(]+?)(?:\s+\((.+)\))?$/)
if (!matcher.matches()) {
def line = rawLine.replace('\r', '').trim()
if (!line || line.length() < 42) {
return
}
def remainder = line.substring(1).trim()
def firstSpaceIndex = remainder.indexOf(' ')
if (firstSpaceIndex <= 0) {
return
}
def pathPart = remainder.substring(firstSpaceIndex + 1).trim()
def branchInfoIndex = pathPart.indexOf(' (')
def submodulePath = (branchInfoIndex >= 0 ? pathPart.substring(0, branchInfoIndex) : pathPart).trim()
if (!submodulePath) {
return
}
def submodulePath = matcher[0][3].trim()
def currentSha = bat(
returnStdout: true,
script: "@echo off\r\ngit -C \"${submodulePath}\" rev-parse HEAD"