fix default branch for .wiki and when using ssh (#284)

This commit is contained in:
eric sciple 2020-06-18 10:20:33 -04:00 committed by GitHub
parent b4483adec3
commit fb6f360df2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 126 additions and 29 deletions

View file

@ -19,17 +19,6 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
)
const repositoryUrl = urlHelper.getFetchUrl(settings)
// Determine the default branch
if (!settings.ref && !settings.commit) {
core.startGroup('Determining the default branch')
settings.ref = await githubApiHelper.getDefaultBranch(
settings.authToken,
settings.repositoryOwner,
settings.repositoryName
)
core.endGroup()
}
// Remove conflicting file path
if (fsHelper.fileExistsSync(settings.repositoryPath)) {
await io.rmRF(settings.repositoryPath)
@ -114,6 +103,21 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
await authHelper.configureAuth()
core.endGroup()
// Determine the default branch
if (!settings.ref && !settings.commit) {
core.startGroup('Determining the default branch')
if (settings.sshKey) {
settings.ref = await git.getDefaultBranch(repositoryUrl)
} else {
settings.ref = await githubApiHelper.getDefaultBranch(
settings.authToken,
settings.repositoryOwner,
settings.repositoryName
)
}
core.endGroup()
}
// LFS install
if (settings.lfs) {
await git.lfsInstall()