My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

mfinfo 1.8KB

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