Skip to content

Commit

Permalink
Merge pull request #54 from Zeit-Labs/apple_git
Browse files Browse the repository at this point in the history
fix: support Apple Git
  • Loading branch information
OmarIthawi authored Jun 5, 2024
2 parents cfa4cf4 + a9aa01c commit 61071f7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion atlas
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ display_pull_params() {

check_git_version() {
MINIMUM_GIT_VERSION="2.25.0" # The `git sparse-checkout` subcommand was introduced in 2.25.0
GIT_VERSION=$(git --version | grep 'git version' | sed -e 's/git version //g')
GIT_VERSION=$(git --version | grep 'git version' | sed -e 's/ .Apple Git-.*//gI' | sed -e 's/git version //g')

# Check if GIT_VERSION is a valid version number
if ! echo "$GIT_VERSION" | grep -Eq '^[0-9]+(\.[0-9]+){1,3}$';
Expand Down
29 changes: 29 additions & 0 deletions spec/minimum_git_version_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,35 @@ Describe 'Works on version 2.25.0'
End


Describe 'Works on Apple git 2.39.3 / Apple Git-146'
git() {
echo 'git version 2.39.3 (Apple Git-146)'
}

Include ./atlas

It 'Works'
When call check_git_version
The status should be success
End
End


Describe 'Fails on Apple git 2.19.3 / Apple Git-50'
git() {
echo 'git version 2.19.3 (Apple Git-50)'
}

Include ./atlas

It 'Detect the version correctly and fails'
When call check_git_version
The output should equal 'Git version 2.19.3 is not supported. Please upgrade to 2.25.0 or higher.'
The status should be failure
End
End


Describe 'Require git version 2.25.0 at least'
git() {
echo "git version 2.20.1"
Expand Down

0 comments on commit 61071f7

Please sign in to comment.