mirror of
				https://github.com/actions/checkout.git
				synced 2025-11-04 14:48:39 +08:00 
			
		
		
		
	Support sparse checkout/LFS better
Instead of fetching all the LFS objects present in the current revision in a sparse checkout, whether they are needed inside the sparse cone or not, let's instead only pull the ones that are actually needed. To do that, let's avoid running that preemptive `git lfs fetch` call in case of a sparse checkout. An alternative that was considered during the development of this patch (and ultimately rejected) was to use `git lfs pull --include <path>...`, but it turned out to be too inflexible because it requires exact paths, not the patterns that are available via the sparse checkout definition, and that risks running into command-line length limitations. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
		
							parent
							
								
									1b203d18c7
								
							
						
					
					
						commit
						25d6c12a40
					
				
							
								
								
									
										3
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| 
						 | 
					@ -1267,7 +1267,8 @@ function getSource(settings) {
 | 
				
			||||||
            // LFS fetch
 | 
					            // LFS fetch
 | 
				
			||||||
            // Explicit lfs-fetch to avoid slow checkout (fetches one lfs object at a time).
 | 
					            // Explicit lfs-fetch to avoid slow checkout (fetches one lfs object at a time).
 | 
				
			||||||
            // Explicit lfs fetch will fetch lfs objects in parallel.
 | 
					            // Explicit lfs fetch will fetch lfs objects in parallel.
 | 
				
			||||||
            if (settings.lfs) {
 | 
					            // For sparse checkouts, let `checkout` fetch the needed objects lazily.
 | 
				
			||||||
 | 
					            if (settings.lfs && !settings.sparseCheckout) {
 | 
				
			||||||
                core.startGroup('Fetching LFS objects');
 | 
					                core.startGroup('Fetching LFS objects');
 | 
				
			||||||
                yield git.lfsFetch(checkoutInfo.startPoint || checkoutInfo.ref);
 | 
					                yield git.lfsFetch(checkoutInfo.startPoint || checkoutInfo.ref);
 | 
				
			||||||
                core.endGroup();
 | 
					                core.endGroup();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -188,7 +188,8 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
 | 
				
			||||||
    // LFS fetch
 | 
					    // LFS fetch
 | 
				
			||||||
    // Explicit lfs-fetch to avoid slow checkout (fetches one lfs object at a time).
 | 
					    // Explicit lfs-fetch to avoid slow checkout (fetches one lfs object at a time).
 | 
				
			||||||
    // Explicit lfs fetch will fetch lfs objects in parallel.
 | 
					    // Explicit lfs fetch will fetch lfs objects in parallel.
 | 
				
			||||||
    if (settings.lfs) {
 | 
					    // For sparse checkouts, let `checkout` fetch the needed objects lazily.
 | 
				
			||||||
 | 
					    if (settings.lfs && !settings.sparseCheckout) {
 | 
				
			||||||
      core.startGroup('Fetching LFS objects')
 | 
					      core.startGroup('Fetching LFS objects')
 | 
				
			||||||
      await git.lfsFetch(checkoutInfo.startPoint || checkoutInfo.ref)
 | 
					      await git.lfsFetch(checkoutInfo.startPoint || checkoutInfo.ref)
 | 
				
			||||||
      core.endGroup()
 | 
					      core.endGroup()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user