mirror of
https://github.com/actions/checkout.git
synced 2024-11-15 11:54:30 +08:00
change: remove path.sep, add unit tests, dist
Remove path.sep during comparison with repositoryPath (did not take in account root folders) Updated and added more unit tests Updated dist/index.js
This commit is contained in:
parent
21ffcee746
commit
8461fff5eb
@ -825,7 +825,6 @@ async function setup(testName: string): Promise<void> {
|
|||||||
workflowOrganizationId: 123456,
|
workflowOrganizationId: 123456,
|
||||||
setSafeDirectory: true,
|
setSafeDirectory: true,
|
||||||
githubServerUrl: githubServerUrl,
|
githubServerUrl: githubServerUrl,
|
||||||
workingDirectory: undefined
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,4 +144,25 @@ describe('input-helper tests', () => {
|
|||||||
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
||||||
expect(settings.workflowOrganizationId).toBe(123456)
|
expect(settings.workflowOrganizationId).toBe(123456)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('sets a different working directory', async() => {
|
||||||
|
inputs['working-directory'] = '/home/user/test'
|
||||||
|
inputs['path'] = 'path/to/repo'
|
||||||
|
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
||||||
|
expect(settings.repositoryPath).toBe(path.resolve('/home/user/test/path/to/repo'))
|
||||||
|
})
|
||||||
|
|
||||||
|
it('sets a working directory on root', async() => {
|
||||||
|
inputs['working-directory'] = '/'
|
||||||
|
inputs['path'] = 'path/to/repo'
|
||||||
|
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
||||||
|
expect(settings.repositoryPath).toBe(path.resolve('/path/to/repo'))
|
||||||
|
})
|
||||||
|
|
||||||
|
it('sets a working directory on root and repository path is set to empty', async() => {
|
||||||
|
inputs['working-directory'] = '/'
|
||||||
|
inputs['path'] = ''
|
||||||
|
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
||||||
|
expect(settings.repositoryPath).toBe(path.resolve('/'))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -43,11 +43,11 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
!(result.repositoryPath + path.sep).startsWith(
|
!(result.repositoryPath + path.sep).startsWith(
|
||||||
workingDirectory + path.sep
|
workingDirectory
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Repository path '${result.repositoryPath}' is not under '${workingDirectory}'`
|
`Repository path '${result.repositoryPath + path.sep}' is not under '${workingDirectory}'`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user