My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

mfinfo 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env bash
  2. #
  3. # mfinfo
  4. #
  5. # Print the following info about the working copy:
  6. #
  7. # - Remote (upstream) Org name (MarlinFirmware)
  8. # - Remote (origin) Org name (your Github username)
  9. # - Repo Name (Marlin, MarlinDocumentation)
  10. # - PR Target branch (e.g., bugfix-2.1.x)
  11. # - Branch Arg (the branch argument or current branch)
  12. # - Current Branch
  13. #
  14. # Example output
  15. # > mfinfo -q ongoing
  16. # MarlinFirmware john.doe Marlin bugfix-2.1.x ongoing bugfix-2.1.x -q
  17. #
  18. CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g')
  19. [[ -z $CURR ]] && { echo "No git repository here!" 1>&2 ; exit 1; }
  20. [[ $CURR == "(no"* ]] && { echo "Git is busy with merge, rebase, etc." 1>&2 ; exit 1; }
  21. REPO=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*\/(.*)\.git/\1/')
  22. [[ -z $REPO ]] && { echo "`basename $0`: No 'upstream' remote found. (Did you run mfinit?)" 1>&2 ; exit 1; }
  23. ORG=$(git remote get-url upstream 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
  24. [[ $ORG == MarlinFirmware ]] || { echo "`basename $0`: Not a Marlin repository." 1>&2 ; exit 1; }
  25. FORK=$(git remote get-url origin 2>/dev/null | sed -E 's/.*[\/:](.*)\/.*$/\1/')
  26. # Defaults if no arguments given
  27. BRANCH=$CURR
  28. MORE=""
  29. INDEX=2
  30. # Loop through arguments
  31. while [[ $# -gt 0 ]]; do
  32. # Get an arg and maybe a val to go with it
  33. opt="$1" ; shift ; val="$1"
  34. # Split up an arg containing =
  35. IFS='=' read -a PARTS <<<"$opt"
  36. [[ "${PARTS[1]}" != "" ]] && { EQUALS=1 ; opt="${PARTS[0]}" ; val="${PARTS[1]}" ; }
  37. if [[ "$val" =~ ^-{1,2}.* || ! "$opt" =~ ^-{1,2}.* ]]; then
  38. val=""
  39. fi
  40. case "$opt" in
  41. -*|--*) MORE=" $MORE$opt" ; ((EQUALS)) && MORE="$MORE=$val" ;;
  42. 1|2) INDEX=$opt ;;
  43. *) BRANCH="$opt" ;;
  44. esac
  45. done
  46. case "$REPO" in
  47. Marlin ) TARG=bugfix-2.1.x ; ((INDEX == 1)) && TARG=bugfix-1.1.x ; [[ $BRANCH =~ ^[12]$ ]] && USAGE=1 ;;
  48. Configurations ) TARG=import-2.0.x ;;
  49. MarlinDocumentation ) TARG=master ;;
  50. AutoBuildMarlin ) TARG=master ;;
  51. esac
  52. [[ $USAGE == 1 ]] && { echo "usage: `basename $0` [1|2] [branch]" 1>&2 ; exit 1 ; }
  53. echo "$ORG $FORK $REPO $TARG $BRANCH $CURR$MORE"