|
1 | 1 | #!/bin/bash |
2 | 2 | # Prompt for a branch name with a default |
3 | 3 | prompt_for_branch() { |
4 | | - read -p "Enter the name of the $1 branch (default: $2): " branch |
| 4 | + read -rp "Enter the name of the $1 branch (default: $2): " branch |
5 | 5 | echo "${branch:-$2}" # Return the entered branch name or the default if none was entered |
6 | 6 | } |
7 | 7 |
|
@@ -32,35 +32,35 @@ process_branch() { |
32 | 32 | local branch_name=$1 |
33 | 33 | local temp_branch="temp_${branch_name}_$$" |
34 | 34 | if $UPDATE_BRANCHES; then |
35 | | - git checkout $branch_name &> /dev/null |
36 | | - git pull origin $branch_name &> /dev/null |
| 35 | + git checkout "$branch_name" &> /dev/null |
| 36 | + git pull origin "$branch_name" &> /dev/null |
37 | 37 | echo "$branch_name" |
38 | 38 | else |
39 | | - git fetch origin $branch_name:$temp_branch &> /dev/null |
40 | | - echo $temp_branch |
| 39 | + git fetch origin "$branch_name":"$temp_branch" &> /dev/null |
| 40 | + echo "$temp_branch" |
41 | 41 | fi |
42 | 42 | } |
43 | 43 |
|
44 | 44 | # Process the first branch |
45 | | -BRANCH1=$(process_branch $BRANCH1) |
| 45 | +BRANCH1=$(process_branch "$BRANCH1") |
46 | 46 |
|
47 | 47 | # Process the second branch |
48 | | -BRANCH2=$(process_branch $BRANCH2) |
| 48 | +BRANCH2=$(process_branch "$BRANCH2") |
49 | 49 |
|
50 | 50 | # If not updating branches, use the temporary branches for log |
51 | 51 | if ! $UPDATE_BRANCHES; then |
52 | 52 | # Run the git log command and process the output on temporary branches |
53 | | - git log $BRANCH2..$BRANCH1 --oneline --no-merges | grep -Eio "(\w+)-([0-9]+)" | tr '[:lower:]' '[:upper:]' | sort -u |
| 53 | + git log "$BRANCH2".."$BRANCH1" --oneline --no-merges | grep -Eio "(\w+)-([0-9]+)" | tr '[:lower:]' '[:upper:]' | sort -u |
54 | 54 |
|
55 | 55 | # Delete the temporary branches |
56 | | - git branch -D $BRANCH1 &> /dev/null |
57 | | - git branch -D $BRANCH2 &> /dev/null |
| 56 | + git branch -D "$BRANCH1" &> /dev/null |
| 57 | + git branch -D "$BRANCH2" &> /dev/null |
58 | 58 | git status; |
59 | 59 | else |
60 | 60 | # Run the git log command and process the output on updated branches |
61 | | - git log $BRANCH2..$BRANCH1 --oneline --no-merges | grep -Eio "(\w+)-([0-9]+)" | tr '[:lower:]' '[:upper:]' | sort -u |
| 61 | + git log "$BRANCH2".."$BRANCH1" --oneline --no-merges | grep -Eio "(\w+)-([0-9]+)" | tr '[:lower:]' '[:upper:]' | sort -u |
62 | 62 |
|
63 | 63 | # Checkout to the first branch (assumed to be 'master') |
64 | | - git checkout $BRANCH1 &> /dev/null |
| 64 | + git checkout "$BRANCH1" &> /dev/null |
65 | 65 | git status |
66 | 66 | fi |
0 commit comments