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.

50 lines
2.0 KiB

  1. #!/bin/bash
  2. git fetch origin --prune
  3. export LANG=en_US.UTF-8
  4. LOCAL_BRANCHES_IN_DEVELOP=( $(git branch --merged develop --format "%(refname:short)") )
  5. LOCAL_BRANCHES_WITHOUT_UPSTREAM=( $(git branch --format "%(refname:short) %(upstream) %(upstream:track)" | grep -vE "(develop|master)" | awk '{if ($3 == "[gone]" || !$2) print $1;}') )
  6. if [ ${#LOCAL_BRANCHES_WITHOUT_UPSTREAM[@]} -eq 0 ]; then
  7. echo "Нет веток без remote"
  8. else
  9. LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_MERGED_INTO_DEVELOP=()
  10. for BRANCH_WITHOUT_UPSTREAM in "${LOCAL_BRANCHES_WITHOUT_UPSTREAM[@]}"; do
  11. for BRANCH_MERGED_IN_DEVELOP in "${LOCAL_BRANCHES_IN_DEVELOP[@]}"; do
  12. if [ "$BRANCH_WITHOUT_UPSTREAM" == "$BRANCH_MERGED_IN_DEVELOP" ]; then
  13. LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_MERGED_INTO_DEVELOP+=( "$BRANCH_WITHOUT_UPSTREAM" )
  14. fi
  15. done
  16. done
  17. if [ ${#LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_MERGED_INTO_DEVELOP[@]} -ne 0 ]; then
  18. echo "Ветки без remote и вмерженные в develop"
  19. # echo "${LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_MERGED_INTO_DEVELOP[@]}" | tr " " "\n"
  20. echo "${LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_MERGED_INTO_DEVELOP[@]}"
  21. fi
  22. LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_NOT_MERGED_INTO_DEVELOP=()
  23. for BRANCH_WITHOUT_UPSTREAM in "${LOCAL_BRANCHES_WITHOUT_UPSTREAM[@]}"; do
  24. BRANCH_IS_MERGED_INTO_DEVELOP=0
  25. for BRANCH_MERGED_IN_DEVELOP in "${LOCAL_BRANCHES_IN_DEVELOP[@]}"; do
  26. if [ "$BRANCH_WITHOUT_UPSTREAM" == "$BRANCH_MERGED_IN_DEVELOP" ] ; then
  27. BRANCH_IS_MERGED_INTO_DEVELOP=1
  28. fi
  29. done
  30. if [ $BRANCH_IS_MERGED_INTO_DEVELOP -eq 0 ]; then
  31. LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_NOT_MERGED_INTO_DEVELOP+=( "$BRANCH_WITHOUT_UPSTREAM" )
  32. fi
  33. done
  34. if [ ${#LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_NOT_MERGED_INTO_DEVELOP[@]} -ne 0 ]; then
  35. echo "Ветки без remote, но еще не вмерженные в develop"
  36. # echo "${LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_NOT_MERGED_INTO_DEVELOP[@]}" | tr " " "\n"
  37. echo "${LOCAL_BRANCHES_WITHOUT_UPSTREAM_AND_NOT_MERGED_INTO_DEVELOP[@]}"
  38. fi
  39. fi