mirror of
				https://github.com/actions/checkout.git
				synced 2025-10-31 13:58:09 +08:00 
			
		
		
		
	Fix submodule git directory paths for includeIf
This commit is contained in:
		
							
								
								
									
										15
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -289,16 +289,15 @@ class GitAuthHelper { | ||||
|                 // For each submodule, configure includeIf entries pointing to the shared credentials file.
 | ||||
|                 // Configure both host and container paths to support Docker container actions.
 | ||||
|                 for (const configPath of configPaths) { | ||||
|                     // Submodule path
 | ||||
|                     const submodulePath = path.dirname(path.dirname(configPath)); | ||||
|                     // The config file is at .git/modules/submodule-name/config
 | ||||
|                     let submoduleConfigDir = path.dirname(configPath); | ||||
|                     submoduleConfigDir = submoduleConfigDir.replace(/\\/g, '/'); // Use forward slashes, even on Windows
 | ||||
|                     // Configure host includeIf
 | ||||
|                     let submoduleGitDir = path.join(submodulePath, '.git'); | ||||
|                     submoduleGitDir = submoduleGitDir.replace(/\\/g, '/'); // Use forward slashes, even on Windows
 | ||||
|                     yield this.git.config(`includeIf.gitdir:${submoduleGitDir}.path`, credentialsConfigPath, false, false, configPath); | ||||
|                     yield this.git.config(`includeIf.gitdir:${submoduleConfigDir}.path`, credentialsConfigPath, false, false, configPath); | ||||
|                     // Configure container includeIf
 | ||||
|                     let submoduleRelativePath = path.relative(workingDirectory, submodulePath); | ||||
|                     submoduleRelativePath = submoduleRelativePath.replace(/\\/g, '/'); // Use forward slashes, even on Windows
 | ||||
|                     const containerSubmoduleGitDir = path.posix.join(containerRepoPath, submoduleRelativePath, '.git'); | ||||
|                     let relativeSubmoduleConfigDir = path.relative(githubWorkspace, submoduleConfigDir); | ||||
|                     relativeSubmoduleConfigDir = relativeSubmoduleConfigDir.replace(/\\/g, '/'); // Use forward slashes, even on Windows
 | ||||
|                     const containerSubmoduleGitDir = path.posix.join('/github/workspace', relativeSubmoduleConfigDir); | ||||
|                     yield this.git.config(`includeIf.gitdir:${containerSubmoduleGitDir}.path`, containerCredentialsPath, false, false, configPath); | ||||
|                 } | ||||
|                 if (this.settings.sshKey) { | ||||
|   | ||||
| @@ -205,14 +205,13 @@ class GitAuthHelper { | ||||
|       // For each submodule, configure includeIf entries pointing to the shared credentials file. | ||||
|       // Configure both host and container paths to support Docker container actions. | ||||
|       for (const configPath of configPaths) { | ||||
|         // Submodule path | ||||
|         const submodulePath = path.dirname(path.dirname(configPath)) | ||||
|         // The config file is at .git/modules/submodule-name/config | ||||
|         let submoduleConfigDir = path.dirname(configPath) | ||||
|         submoduleConfigDir = submoduleConfigDir.replace(/\\/g, '/') // Use forward slashes, even on Windows | ||||
|  | ||||
|         // Configure host includeIf | ||||
|         let submoduleGitDir = path.join(submodulePath, '.git') | ||||
|         submoduleGitDir = submoduleGitDir.replace(/\\/g, '/') // Use forward slashes, even on Windows | ||||
|         await this.git.config( | ||||
|           `includeIf.gitdir:${submoduleGitDir}.path`, | ||||
|           `includeIf.gitdir:${submoduleConfigDir}.path`, | ||||
|           credentialsConfigPath, | ||||
|           false, | ||||
|           false, | ||||
| @@ -220,15 +219,11 @@ class GitAuthHelper { | ||||
|         ) | ||||
|  | ||||
|         // Configure container includeIf | ||||
|         let submoduleRelativePath = path.relative( | ||||
|           workingDirectory, | ||||
|           submodulePath | ||||
|         ) | ||||
|         submoduleRelativePath = submoduleRelativePath.replace(/\\/g, '/') // Use forward slashes, even on Windows | ||||
|         let relativeSubmoduleConfigDir = path.relative(githubWorkspace, submoduleConfigDir) | ||||
|         relativeSubmoduleConfigDir = relativeSubmoduleConfigDir.replace(/\\/g, '/') // Use forward slashes, even on Windows | ||||
|         const containerSubmoduleGitDir = path.posix.join( | ||||
|           containerRepoPath, | ||||
|           submoduleRelativePath, | ||||
|           '.git' | ||||
|           '/github/workspace', | ||||
|           relativeSubmoduleConfigDir | ||||
|         ) | ||||
|         await this.git.config( | ||||
|           `includeIf.gitdir:${containerSubmoduleGitDir}.path`, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user