functions.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/env bash
  2. source $HOME/.colors &>/dev/null
  3. function translate() {
  4. typing=$(mktemp)
  5. rm -rf $typing && nano $typing
  6. msg=$(trans -b :en -no-auto -i $typing)
  7. typing=$(cat $typing)
  8. echo "${BOL_RED}Message:${BOL_YEL}${msg}${END}"
  9. }
  10. function gitpush() {
  11. pwd=$(pwd | cut -c-27)
  12. if [[ $pwd = "/run/media/kleidione/Source" ]]; then
  13. echo "${BOL_RED}No push!${END}"
  14. else
  15. if [[ ${1} = amend ]]; then
  16. echo "${BOL_YEL}Pushing with --force!${END}"
  17. git push -f
  18. else
  19. echo "${BOL_YEL}Pushing!${END}"
  20. git push
  21. fi
  22. fi
  23. }
  24. function cm() {
  25. translate
  26. if [[ ${1} ]]; then
  27. git commit --author "${1}" --date "$(date)" && gitpush
  28. else
  29. git commit --message $msg --signoff --author "kleidione Freitas <kleidione@gmail.com>" --date "$(date)" && gitpush
  30. fi
  31. }
  32. function amend() {
  33. if [[ ${1} ]]; then
  34. git commit --author "${1}" --signoff --amend --date "$(date)" && gitpush amend
  35. else
  36. git commit --signoff --amend --date "$(date)" && gitpush amend
  37. fi
  38. }
  39. function push() {
  40. REPO=$(pwd | sed "s/\/run\/media\/kleidione\/Source\/KRAKEN\///; s/\//_/g")
  41. echo $REPO
  42. GITHOST=github
  43. ORG=AOSPK-WIP
  44. BRANCH=eleven
  45. FORCE=${1}
  46. TOPIC=${2}
  47. if [[ $REPO = "vendor_gapps" || $REPO = "vendor_google_gms" ]]; then
  48. GITHOST=gitlab
  49. ORG=AOSPK
  50. fi
  51. if [[ $REPO = "www" ]]; then
  52. ORG=AOSPK
  53. BRANCH=master
  54. fi
  55. if [[ $REPO = "build_make" ]]; then
  56. REPO=build
  57. fi
  58. if [[ $REPO = "packages_apps_PermissionController" ]]; then
  59. REPO=packages_apps_PackageInstaller
  60. fi
  61. if [[ $REPO = "vendor_qcom_opensource_commonsys-intf_bluetooth" ]]; then
  62. REPO=vendor_qcom_opensource_bluetooth-commonsys-intf
  63. fi
  64. if [[ $REPO = "vendor_qcom_opensource_commonsys-intf_display" ]]; then
  65. REPO=vendor_qcom_opensource_display-commonsys-intf
  66. fi
  67. if [[ $REPO = "vendor_qcom_opensource_commonsys_bluetooth_ext" ]]; then
  68. REPO=vendor_qcom_opensource_bluetooth_ext
  69. fi
  70. if [[ $REPO = "vendor_qcom_opensource_commonsys_packages_apps_Bluetooth" ]]; then
  71. REPO=vendor_qcom_opensource_packages_apps_Bluetooth
  72. fi
  73. if [[ $REPO = "vendor_qcom_opensource_commonsys_system_bt" ]]; then
  74. REPO=vendor_qcom_opensource_system_bt
  75. fi
  76. if [[ ${1} = "gerrit" ]]; then
  77. echo "${BOL_BLU}Pushing to gerrit.aospk.org/${GRE}${ORG}${END}/${BLU}${REPO}${END} - ${BRANCH} ${RED}${FORCE}${END}"
  78. if [ -z "${TOPIC}" ]
  79. then
  80. git push ssh://kleidione@gerrit.aospk.org:29418/${REPO} HEAD:refs/for/${BRANCH}
  81. else
  82. git push ssh://kleidione@gerrit.aospk.org:29418/${REPO} HEAD:refs/for/${BRANCH}%topic=${TOPIC}
  83. fi
  84. else
  85. echo "${BOL_BLU}Pushing to ${GITHOST}.com/${GRE}${ORG}${END}/${BLU}${REPO}${END} - ${BRANCH} ${RED}${FORCE}${END}"
  86. git push ssh://git@${GITHOST}.com/${ORG}/${REPO} HEAD:refs/heads/${BRANCH} ${FORCE}
  87. fi
  88. }