mirror of
				https://github.com/actions/checkout.git
				synced 2025-11-04 07:48:09 +08:00 
			
		
		
		
	Add option to fetch tags even if fetch-depth > 0 (#579)
* Add option to fetch tags even if fetch-depth > 0 * Add jest tests for fetchDepth and fetchTags options
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							96f53100ba
						
					
				
				
					commit
					7739b9ba2e
				
			@@ -153,7 +153,11 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
 | 
			
		||||
 | 
			
		||||
    // Fetch
 | 
			
		||||
    core.startGroup('Fetching the repository')
 | 
			
		||||
    const fetchOptions: {filter?: string; fetchDepth?: number} = {}
 | 
			
		||||
    const fetchOptions: {
 | 
			
		||||
      filter?: string
 | 
			
		||||
      fetchDepth?: number
 | 
			
		||||
      fetchTags?: boolean
 | 
			
		||||
    } = {}
 | 
			
		||||
    if (settings.sparseCheckout) fetchOptions.filter = 'blob:none'
 | 
			
		||||
    if (settings.fetchDepth <= 0) {
 | 
			
		||||
      // Fetch all branches and tags
 | 
			
		||||
@@ -171,6 +175,7 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
      fetchOptions.fetchDepth = settings.fetchDepth
 | 
			
		||||
      fetchOptions.fetchTags = settings.fetchTags
 | 
			
		||||
      const refSpec = refHelper.getRefSpec(settings.ref, settings.commit)
 | 
			
		||||
      await git.fetch(refSpec, fetchOptions)
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user