mirror of
				https://github.com/actions/checkout.git
				synced 2025-11-04 07:30:54 +00:00 
			
		
		
		
	Run format, lint and build
Signed-off-by: Luca Comellini <luca.com@gmail.com>
This commit is contained in:
		
					parent
					
						
							
								44c2b7a8a4
							
						
					
				
			
			
				commit
				
					
						b260373e81
					
				
			
		
					 9 changed files with 9720 additions and 29471 deletions
				
			
		| 
						 | 
					@ -169,9 +169,8 @@ describe('git-auth-helper tests', () => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Mock fs.promises.readFile
 | 
					    // Mock fs.promises.readFile
 | 
				
			||||||
    const realReadFile = fs.promises.readFile
 | 
					    const realReadFile = fs.promises.readFile
 | 
				
			||||||
    jest
 | 
					    jest.spyOn(fs.promises, 'readFile').mockImplementation(
 | 
				
			||||||
      .spyOn(fs.promises, 'readFile')
 | 
					      async (file: any, options: any): Promise<Buffer> => {
 | 
				
			||||||
      .mockImplementation(async (file: any, options: any): Promise<Buffer> => {
 | 
					 | 
				
			||||||
        const userKnownHostsPath = path.join(
 | 
					        const userKnownHostsPath = path.join(
 | 
				
			||||||
          os.homedir(),
 | 
					          os.homedir(),
 | 
				
			||||||
          '.ssh',
 | 
					          '.ssh',
 | 
				
			||||||
| 
						 | 
					@ -182,7 +181,8 @@ describe('git-auth-helper tests', () => {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return await realReadFile(file, options)
 | 
					        return await realReadFile(file, options)
 | 
				
			||||||
      })
 | 
					      }
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Act
 | 
					    // Act
 | 
				
			||||||
    const authHelper = gitAuthHelper.createAuthHelper(git, settings)
 | 
					    const authHelper = gitAuthHelper.createAuthHelper(git, settings)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,11 +7,11 @@ let git: IGitCommandManager
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe('ref-helper tests', () => {
 | 
					describe('ref-helper tests', () => {
 | 
				
			||||||
  beforeEach(() => {
 | 
					  beforeEach(() => {
 | 
				
			||||||
    git = {} as unknown as IGitCommandManager
 | 
					    git = ({} as unknown) as IGitCommandManager
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('getCheckoutInfo requires git', async () => {
 | 
					  it('getCheckoutInfo requires git', async () => {
 | 
				
			||||||
    const git = null as unknown as IGitCommandManager
 | 
					    const git = (null as unknown) as IGitCommandManager
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      await refHelper.getCheckoutInfo(git, 'refs/heads/my/branch', commit)
 | 
					      await refHelper.getCheckoutInfo(git, 'refs/heads/my/branch', commit)
 | 
				
			||||||
      throw new Error('Should not reach here')
 | 
					      throw new Error('Should not reach here')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,7 +68,7 @@ describe('retry-helper tests', () => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('all attempts fail succeeds', async () => {
 | 
					  it('all attempts fail succeeds', async () => {
 | 
				
			||||||
    let attempts = 0
 | 
					    let attempts = 0
 | 
				
			||||||
    let error: Error = null as unknown as Error
 | 
					    let error: Error = (null as unknown) as Error
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      await retryHelper.execute(() => {
 | 
					      await retryHelper.execute(() => {
 | 
				
			||||||
        throw new Error(`some error ${++attempts}`)
 | 
					        throw new Error(`some error ${++attempts}`)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										39148
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										39148
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
					@ -18,9 +18,8 @@ export function directoryExistsSync(path: string, required?: boolean): boolean {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    throw new Error(
 | 
					    throw new Error(
 | 
				
			||||||
      `Encountered an error when checking whether path '${path}' exists: ${
 | 
					      `Encountered an error when checking whether path '${path}' exists: ${(error as any)
 | 
				
			||||||
        (error as any)?.message ?? error
 | 
					        ?.message ?? error}`
 | 
				
			||||||
      }`
 | 
					 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,9 +45,8 @@ export function existsSync(path: string): boolean {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    throw new Error(
 | 
					    throw new Error(
 | 
				
			||||||
      `Encountered an error when checking whether path '${path}' exists: ${
 | 
					      `Encountered an error when checking whether path '${path}' exists: ${(error as any)
 | 
				
			||||||
        (error as any)?.message ?? error
 | 
					        ?.message ?? error}`
 | 
				
			||||||
      }`
 | 
					 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,9 +67,8 @@ export function fileExistsSync(path: string): boolean {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    throw new Error(
 | 
					    throw new Error(
 | 
				
			||||||
      `Encountered an error when checking whether path '${path}' exists: ${
 | 
					      `Encountered an error when checking whether path '${path}' exists: ${(error as any)
 | 
				
			||||||
        (error as any)?.message ?? error
 | 
					        ?.message ?? error}`
 | 
				
			||||||
      }`
 | 
					 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,7 +49,7 @@ class GitAuthHelper {
 | 
				
			||||||
    gitSourceSettings: IGitSourceSettings | undefined
 | 
					    gitSourceSettings: IGitSourceSettings | undefined
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    this.git = gitCommandManager
 | 
					    this.git = gitCommandManager
 | 
				
			||||||
    this.settings = gitSourceSettings || ({} as unknown as IGitSourceSettings)
 | 
					    this.settings = gitSourceSettings || (({} as unknown) as IGitSourceSettings)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Token auth header
 | 
					    // Token auth header
 | 
				
			||||||
    const serverUrl = urlHelper.getServerUrl(this.settings.githubServerUrl)
 | 
					    const serverUrl = urlHelper.getServerUrl(this.settings.githubServerUrl)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@ import * as workflowContextHelper from './workflow-context-helper'
 | 
				
			||||||
import {IGitSourceSettings} from './git-source-settings'
 | 
					import {IGitSourceSettings} from './git-source-settings'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function getInputs(): Promise<IGitSourceSettings> {
 | 
					export async function getInputs(): Promise<IGitSourceSettings> {
 | 
				
			||||||
  const result = {} as unknown as IGitSourceSettings
 | 
					  const result = ({} as unknown) as IGitSourceSettings
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // GitHub workspace
 | 
					  // GitHub workspace
 | 
				
			||||||
  let githubWorkspacePath = process.env['GITHUB_WORKSPACE']
 | 
					  let githubWorkspacePath = process.env['GITHUB_WORKSPACE']
 | 
				
			||||||
| 
						 | 
					@ -150,8 +150,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
 | 
				
			||||||
    (core.getInput('persist-credentials') || 'false').toUpperCase() === 'TRUE'
 | 
					    (core.getInput('persist-credentials') || 'false').toUpperCase() === 'TRUE'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Workflow organization ID
 | 
					  // Workflow organization ID
 | 
				
			||||||
  result.workflowOrganizationId =
 | 
					  result.workflowOrganizationId = await workflowContextHelper.getOrganizationId()
 | 
				
			||||||
    await workflowContextHelper.getOrganizationId()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Set safe.directory in git global config.
 | 
					  // Set safe.directory in git global config.
 | 
				
			||||||
  result.setSafeDirectory =
 | 
					  result.setSafeDirectory =
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@ export async function getCheckoutInfo(
 | 
				
			||||||
    throw new Error('Args ref and commit cannot both be empty')
 | 
					    throw new Error('Args ref and commit cannot both be empty')
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const result = {} as unknown as ICheckoutInfo
 | 
					  const result = ({} as unknown) as ICheckoutInfo
 | 
				
			||||||
  const upperRef = (ref || '').toUpperCase()
 | 
					  const upperRef = (ref || '').toUpperCase()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // SHA only
 | 
					  // SHA only
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,9 +23,8 @@ export async function getOrganizationId(): Promise<number | undefined> {
 | 
				
			||||||
    return id as number
 | 
					    return id as number
 | 
				
			||||||
  } catch (err) {
 | 
					  } catch (err) {
 | 
				
			||||||
    core.debug(
 | 
					    core.debug(
 | 
				
			||||||
      `Unable to load organization ID from GITHUB_EVENT_PATH: ${
 | 
					      `Unable to load organization ID from GITHUB_EVENT_PATH: ${(err as any)
 | 
				
			||||||
        (err as any).message || err
 | 
					        .message || err}`
 | 
				
			||||||
      }`
 | 
					 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue