forked from ShelterTechSF/askdarcel-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
open-pr.sh
24 lines (19 loc) · 871 Bytes
/
open-pr.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
# Colors for fun and profit
BOLD="\033[1m"
YELLOW="\033[38;5;11m"
RESET="\033[0m"
# Get the current branch name
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
# Set base branch to `development`
# The IMPORTANT part 😅
URL="https://github.com/Exygy/askdarcel-web/compare/development...Exygy:askdarcel-web:${BRANCH_NAME}?expand=1"
# Localize rules for affirmative and negative responses (LC_MESSAGES) and write them to environment variables
set -- $(locale LC_MESSAGES)
yesexpr="$1"; noexpr="$2"; yesword="$3"; noword="$4"
# Prompt loop
while true; do
read -p "Open a PR for your branch $(printf $BOLD$YELLOW$BRANCH_NAME$RESET) (${yesword}/${noword})? " yn
if [[ "$yn" =~ $yesexpr ]]; then open $URL; echo "Yay, happy code review! 👏👏👏"; exit; fi
if [[ "$yn" =~ $noexpr ]]; then echo "Oh ok. Happy coding! 👩💻"; exit; fi
done