fix: Check if repo is shallow before unshallowing

releases/v3
Tycho Bokdam 2020-10-30 23:21:44 +01:00
parent f0fabf6d88
commit c5bb2b18af
No known key found for this signature in database
GPG Key ID: A0FAE77C8CDF33C7
2 changed files with 1908 additions and 3 deletions

View File

@ -96,9 +96,18 @@ module.exports = new (class Git {
* *
* @return {Promise<>} * @return {Promise<>}
*/ */
pull = () => ( pull = async() => {
this.exec(`pull --unshallow --tags ${core.getInput('git-pull-method')}`) const args = ['pull']
)
// Check if the repo is unshallow
if (await this.isShallow()) {
args.push('--unshallow')
}
args.push(core.getInput('git-pull-method'))
return this.exec(args.join(' '))
}
/** /**
* Push all changes * Push all changes
@ -109,6 +118,17 @@ module.exports = new (class Git {
this.exec(`push origin ${branch} --follow-tags`) this.exec(`push origin ${branch} --follow-tags`)
) )
/**
* Check if the repo is shallow
*
* @return {Promise<>}
*/
isShallow = async () => {
const isShallow = await this.exec('rev-parse --is-shallow-repository')
return isShallow.trim().replace('\n', '') === 'true'
}
/** /**
* Updates the origin remote * Updates the origin remote
* *

1885
yarn.lock 100644

File diff suppressed because it is too large Load Diff