Skip to content

Commit

Permalink
fix: Check if repo is shallow before unshallowing
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs committed Oct 30, 2020
1 parent f0fabf6 commit c5bb2b1
Show file tree
Hide file tree
Showing 2 changed files with 1,908 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/helpers/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,18 @@ module.exports = new (class Git {
*
* @return {Promise<>}
*/
pull = () => (
this.exec(`pull --unshallow --tags ${core.getInput('git-pull-method')}`)
)
pull = async() => {
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
Expand All @@ -109,6 +118,17 @@ module.exports = new (class Git {
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
*
Expand Down
Loading

0 comments on commit c5bb2b1

Please sign in to comment.