get_repo.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. mkdir -p vscode
  3. cd vscode
  4. git init -q
  5. git remote add origin https://github.com/Microsoft/vscode.git
  6. # figure out latest tag by calling MS update API
  7. if [ "$INSIDER" == "1" ]; then
  8. UPDATE_INFO=$(curl https://update.code.visualstudio.com/api/update/darwin/insider/lol)
  9. export MS_COMMIT=$(echo $UPDATE_INFO | jq -r '.version')
  10. export MS_TAG=$(echo $UPDATE_INFO | jq -r '.name')
  11. elif [[ -z "${MS_TAG}" ]]; then
  12. UPDATE_INFO=$(curl https://update.code.visualstudio.com/api/update/darwin/stable/lol)
  13. export MS_COMMIT=$(echo $UPDATE_INFO | jq -r '.version')
  14. export MS_TAG=$(echo $UPDATE_INFO | jq -r '.name')
  15. else
  16. reference=$( git ls-remote --tags | grep -x ".*refs\/tags\/${MS_TAG}" | head -1 )
  17. if [[ -z "${reference}" ]]; then
  18. echo "The following tag can't be found: ${MS_TAG}"
  19. exit 1
  20. elif [[ "${reference}" =~ ^([[:alnum:]]+)[[:space:]]+refs\/tags\/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
  21. export MS_COMMIT="${BASH_REMATCH[1]}"
  22. export MS_TAG="${BASH_REMATCH[2]}"
  23. else
  24. echo "The following reference can't be parsed: ${reference}"
  25. exit 1
  26. fi
  27. fi
  28. echo "Got the MS tag: ${MS_TAG} version: ${MS_COMMIT}"
  29. git fetch --depth 1 origin $MS_COMMIT
  30. git checkout FETCH_HEAD
  31. cd ..
  32. # for GH actions
  33. if [[ $GITHUB_ENV ]]; then
  34. echo "MS_TAG=$MS_TAG" >> $GITHUB_ENV
  35. echo "MS_COMMIT=$MS_COMMIT" >> $GITHUB_ENV
  36. fi