Skip to content

teach getBranches to exit early if folder isn't a Git repository - #5299

Merged
outofambit merged 3 commits into
masterfrom
for-each-ref-should-handle-missing
Jul 31, 2018
Merged

outofambit merged 3 commits into
masterfrom
for-each-ref-should-handle-missing

Conversation

@shiftkey

Copy link
Copy Markdown
Member

In the similar vein as #5298, getBranches is happily run against a folder that doesn't contain a .git directory. For safety's sake, we can just exit early and return an empty array of branches.

This means Git hasn't found a valid repository, and so
there won't be any branches to look at
@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jul 31, 2018
@shiftkey shiftkey added this to the 1.3.2 milestone Jul 31, 2018
})

it('should return empty list for directory without a .git directory', async () => {
const emptyDir = mkdirSync('no-repo-here')

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

repository.path,
'getBranches'
'getBranches',
{ successExitCodes: new Set([0, 128]) }

This comment was marked as spam.

This comment was marked as spam.

@shiftkey

Copy link
Copy Markdown
Member Author

🍎

@outofambit outofambit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@outofambit
outofambit merged commit db66b29 into master Jul 31, 2018
@outofambit
outofambit deleted the for-each-ref-should-handle-missing branch July 31, 2018 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants