mirror of
				https://github.com/actions/checkout.git
				synced 2025-10-31 15:47:36 +00:00 
			
		
		
		
	Fetch all history for all tags and branches when fetch-depth=0 (#258)
This commit is contained in:
		| @@ -3,6 +3,7 @@ import * as exec from '@actions/exec' | ||||
| import * as fshelper from './fs-helper' | ||||
| import * as io from '@actions/io' | ||||
| import * as path from 'path' | ||||
| import * as refHelper from './ref-helper' | ||||
| import * as regexpHelper from './regexp-helper' | ||||
| import * as retryHelper from './retry-helper' | ||||
| import {GitVersion} from './git-version' | ||||
| @@ -23,7 +24,7 @@ export interface IGitCommandManager { | ||||
|     globalConfig?: boolean | ||||
|   ): Promise<void> | ||||
|   configExists(configKey: string, globalConfig?: boolean): Promise<boolean> | ||||
|   fetch(fetchDepth: number, refSpec: string[]): Promise<void> | ||||
|   fetch(refSpec: string[], fetchDepth?: number): Promise<void> | ||||
|   getWorkingDirectory(): string | ||||
|   init(): Promise<void> | ||||
|   isDetached(): Promise<boolean> | ||||
| @@ -32,7 +33,9 @@ export interface IGitCommandManager { | ||||
|   log1(): Promise<string> | ||||
|   remoteAdd(remoteName: string, remoteUrl: string): Promise<void> | ||||
|   removeEnvironmentVariable(name: string): void | ||||
|   revParse(ref: string): Promise<string> | ||||
|   setEnvironmentVariable(name: string, value: string): void | ||||
|   shaExists(sha: string): Promise<boolean> | ||||
|   submoduleForeach(command: string, recursive: boolean): Promise<string> | ||||
|   submoduleSync(recursive: boolean): Promise<void> | ||||
|   submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void> | ||||
| @@ -164,17 +167,14 @@ class GitCommandManager { | ||||
|     return output.exitCode === 0 | ||||
|   } | ||||
|  | ||||
|   async fetch(fetchDepth: number, refSpec: string[]): Promise<void> { | ||||
|     const args = [ | ||||
|       '-c', | ||||
|       'protocol.version=2', | ||||
|       'fetch', | ||||
|       '--no-tags', | ||||
|       '--prune', | ||||
|       '--progress', | ||||
|       '--no-recurse-submodules' | ||||
|     ] | ||||
|     if (fetchDepth > 0) { | ||||
|   async fetch(refSpec: string[], fetchDepth?: number): Promise<void> { | ||||
|     const args = ['-c', 'protocol.version=2', 'fetch'] | ||||
|     if (!refSpec.some(x => x === refHelper.tagsRefSpec)) { | ||||
|       args.push('--no-tags') | ||||
|     } | ||||
|  | ||||
|     args.push('--prune', '--progress', '--no-recurse-submodules') | ||||
|     if (fetchDepth && fetchDepth > 0) { | ||||
|       args.push(`--depth=${fetchDepth}`) | ||||
|     } else if ( | ||||
|       fshelper.fileExistsSync( | ||||
| @@ -238,10 +238,27 @@ class GitCommandManager { | ||||
|     delete this.gitEnv[name] | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Resolves a ref to a SHA. For a branch or lightweight tag, the commit SHA is returned. | ||||
|    * For an annotated tag, the tag SHA is returned. | ||||
|    * @param {string} ref  For example: 'refs/heads/master' or '/refs/tags/v1' | ||||
|    * @returns {Promise<string>} | ||||
|    */ | ||||
|   async revParse(ref: string): Promise<string> { | ||||
|     const output = await this.execGit(['rev-parse', ref]) | ||||
|     return output.stdout.trim() | ||||
|   } | ||||
|  | ||||
|   setEnvironmentVariable(name: string, value: string): void { | ||||
|     this.gitEnv[name] = value | ||||
|   } | ||||
|  | ||||
|   async shaExists(sha: string): Promise<boolean> { | ||||
|     const args = ['rev-parse', '--verify', '--quiet', `${sha}^{object}`] | ||||
|     const output = await this.execGit(args, true) | ||||
|     return output.exitCode === 0 | ||||
|   } | ||||
|  | ||||
|   async submoduleForeach(command: string, recursive: boolean): Promise<string> { | ||||
|     const args = ['submodule', 'foreach'] | ||||
|     if (recursive) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 eric sciple
					eric sciple