You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
939 B

  1. #!/bin/bash
  2. REPO_TYPE=$1
  3. REPO_NAME=$2
  4. function usage {
  5. local BASECMD=$(basename "$0")
  6. echo 'usage: <REPO_TYPE> <REPO_NAME> [DESTINATION]'
  7. echo 'example:'
  8. echo -e '\t# REPO_TYPE=github'
  9. echo -e "\t$BASECMD github Dolibarr/dolibarr\n"
  10. echo -e '\t# REPO_TYPE=artcode'
  11. echo -e "\t$BASECMD artcode pvincent/debian-gnome\n"
  12. exit -1
  13. }
  14. function get_github {
  15. release=$( git ls-remote --tags --sort="v:refname" \
  16. git://github.com/$REPO_NAME \
  17. | tail -n1 | cut -f2 | cut -d '/' -f3 )
  18. release=${release%^\{\}} # remove extra characters ^{} from github
  19. echo $release
  20. }
  21. function get_artcode {
  22. release=$( git ls-remote --tags --sort="v:refname" \
  23. https://git.artcode.re/$REPO_NAME \
  24. | tail -n1 | cut -f2 | cut -d '/' -f3 )
  25. echo $release
  26. }
  27. [[ $# -ne 2 ]] && usage
  28. case $REPO_TYPE in
  29. github )
  30. get_github
  31. ;;
  32. artcode )
  33. get_artcode
  34. ;;
  35. * )
  36. echo "repository type <${REPO_TYPE}> not yet supported!" && exit 1
  37. ;;
  38. esac