mirror of
https://github.com/actions/checkout.git
synced 2025-12-08 12:32:22 +08:00
Simplified the submoduleDirectories
This commit is contained in:
@@ -57,7 +57,7 @@ export interface IGitCommandManager {
|
||||
submoduleUpdate(
|
||||
fetchDepth: number,
|
||||
recursive: boolean,
|
||||
submoduleDirectories: string[] | null
|
||||
submoduleDirectories: string[]
|
||||
): Promise<void>
|
||||
submoduleStatus(): Promise<boolean>
|
||||
tagExists(pattern: string): Promise<boolean>
|
||||
@@ -416,35 +416,25 @@ class GitCommandManager {
|
||||
async submoduleUpdate(
|
||||
fetchDepth: number,
|
||||
recursive: boolean,
|
||||
submoduleDirectories: string[] | null
|
||||
submoduleDirectories: string[]
|
||||
): Promise<void> {
|
||||
if (submoduleDirectories) {
|
||||
for (const submodule of submoduleDirectories) {
|
||||
const args = ['-c', 'protocol.version=2']
|
||||
args.push('submodule', 'update', '--init', '--force', submodule)
|
||||
if (fetchDepth > 0) {
|
||||
args.push(`--depth=${fetchDepth}`)
|
||||
}
|
||||
|
||||
if (recursive) {
|
||||
args.push('--recursive')
|
||||
}
|
||||
|
||||
await this.execGit(args)
|
||||
}
|
||||
} else {
|
||||
const args = ['-c', 'protocol.version=2']
|
||||
args.push('submodule', 'update', '--init', '--force')
|
||||
if (fetchDepth > 0) {
|
||||
args.push(`--depth=${fetchDepth}`)
|
||||
}
|
||||
|
||||
if (recursive) {
|
||||
args.push('--recursive')
|
||||
}
|
||||
|
||||
await this.execGit(args)
|
||||
const args = ['-c', 'protocol.version=2']
|
||||
args.push(
|
||||
'submodule',
|
||||
'update',
|
||||
'--init',
|
||||
'--force',
|
||||
...submoduleDirectories
|
||||
)
|
||||
if (fetchDepth > 0) {
|
||||
args.push(`--depth=${fetchDepth}`)
|
||||
}
|
||||
|
||||
if (recursive) {
|
||||
args.push('--recursive')
|
||||
}
|
||||
|
||||
await this.execGit(args)
|
||||
}
|
||||
|
||||
async submoduleStatus(): Promise<boolean> {
|
||||
|
||||
@@ -77,7 +77,7 @@ export interface IGitSourceSettings {
|
||||
/**
|
||||
* Indicates which submodule paths to checkout
|
||||
*/
|
||||
submoduleDirectories: string[] | null
|
||||
submoduleDirectories: string[]
|
||||
|
||||
/**
|
||||
* The auth token to use when fetching the repository
|
||||
|
||||
@@ -125,7 +125,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
||||
// Submodules
|
||||
result.submodules = false
|
||||
result.nestedSubmodules = false
|
||||
result.submoduleDirectories = null
|
||||
result.submoduleDirectories = []
|
||||
const submodulesString = (core.getInput('submodules') || '').toUpperCase()
|
||||
if (submodulesString == 'RECURSIVE') {
|
||||
result.submodules = true
|
||||
@@ -138,8 +138,6 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
||||
if (submoduleDirectories.length > 0) {
|
||||
result.submoduleDirectories = submoduleDirectories
|
||||
if (!result.submodules) result.submodules = true
|
||||
} else {
|
||||
result.submoduleDirectories = null
|
||||
}
|
||||
|
||||
core.debug(`submodules = ${result.submodules}`)
|
||||
|
||||
Reference in New Issue
Block a user