mirror of
				https://github.com/actions/checkout.git
				synced 2025-10-31 23:43:35 +00:00 
			
		
		
		
	Merge ed2311a594464e30b7189963bdc844e2ab800112 into 8edcb1bdb4e267140fa742c62e395cd74f332709
This commit is contained in:
		
						commit
						ca79052ab8
					
				| @ -1,5 +1,8 @@ | |||||||
| [](https://github.com/actions/checkout/actions/workflows/test.yml) | [](https://github.com/actions/checkout/actions/workflows/test.yml) | ||||||
| 
 | 
 | ||||||
|  | Changes compared to https://github.com/actions/checkout: | ||||||
|  | - Can exclude path when cleaning repository (see `exclude_from_clean` argument) | ||||||
|  | 
 | ||||||
| # Checkout V4 | # Checkout V4 | ||||||
| 
 | 
 | ||||||
| This action checks-out your repository under `$GITHUB_WORKSPACE`, so your workflow can access it. | This action checks-out your repository under `$GITHUB_WORKSPACE`, so your workflow can access it. | ||||||
| @ -96,6 +99,9 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/ | |||||||
|     # Default: true |     # Default: true | ||||||
|     clean: '' |     clean: '' | ||||||
| 
 | 
 | ||||||
|  |     # The path to exclude from cleaning | ||||||
|  |     exclude_from_clean: '' | ||||||
|  | 
 | ||||||
|     # Partially clone against a given filter. Overrides sparse-checkout if set. |     # Partially clone against a given filter. Overrides sparse-checkout if set. | ||||||
|     # Default: null |     # Default: null | ||||||
|     filter: '' |     filter: '' | ||||||
|  | |||||||
| @ -57,6 +57,8 @@ inputs: | |||||||
|   clean: |   clean: | ||||||
|     description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching' |     description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching' | ||||||
|     default: true |     default: true | ||||||
|  |   exclude_from_clean: | ||||||
|  |     description: 'The path to exclude from cleaning' | ||||||
|   filter: |   filter: | ||||||
|     description: > |     description: > | ||||||
|       Partially clone against a given filter. |       Partially clone against a given filter. | ||||||
|  | |||||||
							
								
								
									
										19
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| @ -819,9 +819,15 @@ class GitCommandManager { | |||||||
|             return !!output.stdout.trim(); |             return !!output.stdout.trim(); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|     tryClean() { |     tryClean(exclude_from_clean) { | ||||||
|         return __awaiter(this, void 0, void 0, function* () { |         return __awaiter(this, void 0, void 0, function* () { | ||||||
|             const output = yield this.execGit(['clean', '-ffdx'], true); |             let output; | ||||||
|  |             if (exclude_from_clean) { | ||||||
|  |                 output = yield this.execGit(['clean', '-ffdx', '-e', exclude_from_clean], true); | ||||||
|  |             } | ||||||
|  |             else { | ||||||
|  |                 output = yield this.execGit(['clean', '-ffdx'], true); | ||||||
|  |             } | ||||||
|             return output.exitCode === 0; |             return output.exitCode === 0; | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| @ -1025,7 +1031,7 @@ const fs = __importStar(__nccwpck_require__(7147)); | |||||||
| const fsHelper = __importStar(__nccwpck_require__(7219)); | const fsHelper = __importStar(__nccwpck_require__(7219)); | ||||||
| const io = __importStar(__nccwpck_require__(7436)); | const io = __importStar(__nccwpck_require__(7436)); | ||||||
| const path = __importStar(__nccwpck_require__(1017)); | const path = __importStar(__nccwpck_require__(1017)); | ||||||
| function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean, ref) { | function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean, exclude_from_clean, ref) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         var _a; |         var _a; | ||||||
|         assert.ok(repositoryPath, 'Expected repositoryPath to be defined'); |         assert.ok(repositoryPath, 'Expected repositoryPath to be defined'); | ||||||
| @ -1094,7 +1100,7 @@ function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean, ref | |||||||
|                 // Clean
 |                 // Clean
 | ||||||
|                 if (clean) { |                 if (clean) { | ||||||
|                     core.startGroup('Cleaning the repository'); |                     core.startGroup('Cleaning the repository'); | ||||||
|                     if (!(yield git.tryClean())) { |                     if (!(yield git.tryClean(exclude_from_clean))) { | ||||||
|                         core.debug(`The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For further investigation, manually run 'git clean -ffdx' on the directory '${repositoryPath}'.`); |                         core.debug(`The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For further investigation, manually run 'git clean -ffdx' on the directory '${repositoryPath}'.`); | ||||||
|                         remove = true; |                         remove = true; | ||||||
|                     } |                     } | ||||||
| @ -1216,7 +1222,7 @@ function getSource(settings) { | |||||||
|             } |             } | ||||||
|             // Prepare existing directory, otherwise recreate
 |             // Prepare existing directory, otherwise recreate
 | ||||||
|             if (isExisting) { |             if (isExisting) { | ||||||
|                 yield gitDirectoryHelper.prepareExistingDirectory(git, settings.repositoryPath, repositoryUrl, settings.clean, settings.ref); |                 yield gitDirectoryHelper.prepareExistingDirectory(git, settings.repositoryPath, repositoryUrl, settings.clean, settings.exclude_from_clean, settings.ref); | ||||||
|             } |             } | ||||||
|             if (!git) { |             if (!git) { | ||||||
|                 // Downloading using REST API
 |                 // Downloading using REST API
 | ||||||
| @ -1766,6 +1772,9 @@ function getInputs() { | |||||||
|         // Clean
 |         // Clean
 | ||||||
|         result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE'; |         result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE'; | ||||||
|         core.debug(`clean = ${result.clean}`); |         core.debug(`clean = ${result.clean}`); | ||||||
|  |         // Exclude from clean
 | ||||||
|  |         result.exclude_from_clean = core.getInput('exclude_from_clean'); | ||||||
|  |         core.debug(`exclude_from_clean = ${result.exclude_from_clean}`); | ||||||
|         // Filter
 |         // Filter
 | ||||||
|         const filter = core.getInput('filter'); |         const filter = core.getInput('filter'); | ||||||
|         if (filter) { |         if (filter) { | ||||||
|  | |||||||
							
								
								
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @ -1,12 +1,12 @@ | |||||||
| { | { | ||||||
|   "name": "checkout", |   "name": "checkout", | ||||||
|   "version": "4.2.2", |   "version": "4.2.3", | ||||||
|   "lockfileVersion": 3, |   "lockfileVersion": 3, | ||||||
|   "requires": true, |   "requires": true, | ||||||
|   "packages": { |   "packages": { | ||||||
|     "": { |     "": { | ||||||
|       "name": "checkout", |       "name": "checkout", | ||||||
|       "version": "4.2.2", |       "version": "4.2.3", | ||||||
|       "license": "MIT", |       "license": "MIT", | ||||||
|       "dependencies": { |       "dependencies": { | ||||||
|         "@actions/core": "^1.10.1", |         "@actions/core": "^1.10.1", | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "checkout", |   "name": "checkout", | ||||||
|   "version": "4.2.2", |   "version": "4.2.3", | ||||||
|   "description": "checkout action", |   "description": "checkout action", | ||||||
|   "main": "lib/main.js", |   "main": "lib/main.js", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|  | |||||||
| @ -57,7 +57,7 @@ export interface IGitCommandManager { | |||||||
|   submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void> |   submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void> | ||||||
|   submoduleStatus(): Promise<boolean> |   submoduleStatus(): Promise<boolean> | ||||||
|   tagExists(pattern: string): Promise<boolean> |   tagExists(pattern: string): Promise<boolean> | ||||||
|   tryClean(): Promise<boolean> |   tryClean(exclude_from_clean: string): Promise<boolean> | ||||||
|   tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean> |   tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean> | ||||||
|   tryDisableAutomaticGarbageCollection(): Promise<boolean> |   tryDisableAutomaticGarbageCollection(): Promise<boolean> | ||||||
|   tryGetFetchUrl(): Promise<string> |   tryGetFetchUrl(): Promise<string> | ||||||
| @ -434,8 +434,13 @@ class GitCommandManager { | |||||||
|     return !!output.stdout.trim() |     return !!output.stdout.trim() | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async tryClean(): Promise<boolean> { |   async tryClean(exclude_from_clean: string): Promise<boolean> { | ||||||
|     const output = await this.execGit(['clean', '-ffdx'], true) |     let output | ||||||
|  |     if (exclude_from_clean) { | ||||||
|  |       output = await this.execGit(['clean', '-ffdx', '-e', exclude_from_clean], true) | ||||||
|  |     } else { | ||||||
|  |       output = await this.execGit(['clean', '-ffdx'], true) | ||||||
|  |     } | ||||||
|     return output.exitCode === 0 |     return output.exitCode === 0 | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -11,6 +11,7 @@ export async function prepareExistingDirectory( | |||||||
|   repositoryPath: string, |   repositoryPath: string, | ||||||
|   repositoryUrl: string, |   repositoryUrl: string, | ||||||
|   clean: boolean, |   clean: boolean, | ||||||
|  |   exclude_from_clean: string, | ||||||
|   ref: string |   ref: string | ||||||
| ): Promise<void> { | ): Promise<void> { | ||||||
|   assert.ok(repositoryPath, 'Expected repositoryPath to be defined') |   assert.ok(repositoryPath, 'Expected repositoryPath to be defined') | ||||||
| @ -90,7 +91,7 @@ export async function prepareExistingDirectory( | |||||||
|       // Clean
 |       // Clean
 | ||||||
|       if (clean) { |       if (clean) { | ||||||
|         core.startGroup('Cleaning the repository') |         core.startGroup('Cleaning the repository') | ||||||
|         if (!(await git.tryClean())) { |         if (!(await git.tryClean(exclude_from_clean))) { | ||||||
|           core.debug( |           core.debug( | ||||||
|             `The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For further investigation, manually run 'git clean -ffdx' on the directory '${repositoryPath}'.` |             `The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For further investigation, manually run 'git clean -ffdx' on the directory '${repositoryPath}'.` | ||||||
|           ) |           ) | ||||||
|  | |||||||
| @ -70,6 +70,7 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> { | |||||||
|         settings.repositoryPath, |         settings.repositoryPath, | ||||||
|         repositoryUrl, |         repositoryUrl, | ||||||
|         settings.clean, |         settings.clean, | ||||||
|  |         settings.exclude_from_clean, | ||||||
|         settings.ref |         settings.ref | ||||||
|       ) |       ) | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -29,6 +29,11 @@ export interface IGitSourceSettings { | |||||||
|    */ |    */ | ||||||
|   clean: boolean |   clean: boolean | ||||||
| 
 | 
 | ||||||
|  |   /** | ||||||
|  |    * Indicates path to exclude when cleaning | ||||||
|  |    */ | ||||||
|  |   exclude_from_clean: string | ||||||
|  | 
 | ||||||
|   /** |   /** | ||||||
|    * The filter determining which objects to include |    * The filter determining which objects to include | ||||||
|    */ |    */ | ||||||
|  | |||||||
| @ -82,6 +82,10 @@ export async function getInputs(): Promise<IGitSourceSettings> { | |||||||
|   result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE' |   result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE' | ||||||
|   core.debug(`clean = ${result.clean}`) |   core.debug(`clean = ${result.clean}`) | ||||||
| 
 | 
 | ||||||
|  |   // Exclude from clean
 | ||||||
|  |   result.exclude_from_clean = core.getInput('exclude_from_clean') | ||||||
|  |   core.debug(`exclude_from_clean = ${result.exclude_from_clean}`) | ||||||
|  | 
 | ||||||
|   // Filter
 |   // Filter
 | ||||||
|   const filter = core.getInput('filter') |   const filter = core.getInput('filter') | ||||||
|   if (filter) { |   if (filter) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user