15
15
# See the License for the specific language governing permissions and
16
16
# limitations under the License.
17
17
18
- ROOT_DIR=$( realpath $( dirname " $0 " ) /../..)
19
- cd $ROOT_DIR
18
+ ROOT_DIR=$( realpath " $( dirname " $0 " ) " /../..)
19
+ cd " $ROOT_DIR "
20
20
21
21
get_repo_and_branch_info () {
22
22
# Input validation
@@ -39,7 +39,7 @@ get_repo_and_branch_info() {
39
39
return 1
40
40
fi
41
41
42
- cd $path
42
+ cd " $path "
43
43
44
44
# Get the URL of the remote origin
45
45
remote_url=$( git config --get remote.origin.url)
@@ -54,7 +54,7 @@ get_repo_and_branch_info() {
54
54
padding_length=$(( total_length - text_length))
55
55
56
56
echo ' +-----------------------------------------------------------------------------------------------+'
57
- printf " | %s: %s%*s|\n" " $repo_friendly_name " " $repo_name " $padding_length " "
57
+ printf " | %s: %s%*s|\n" " $repo_friendly_name " " $repo_name " " $padding_length " " "
58
58
echo ' +-----------------------------------------------------------------------------------------------+'
59
59
else
60
60
# Print error message if there is no remote URL
@@ -91,7 +91,7 @@ get_repo_and_branch_info() {
91
91
echo " Commit Date: $commit_datetime "
92
92
93
93
# Attempt to find branches that contain this commit
94
- branches=$( git branch --contains $commit_sha | sed ' s/^/ /' )
94
+ branches=$( git branch --contains " $commit_sha " | sed ' s/^/ /' )
95
95
96
96
if [ -n " $branches " ]; then
97
97
echo " Contained in branches:"
@@ -105,7 +105,7 @@ get_repo_and_branch_info() {
105
105
echo
106
106
107
107
# Navigate back to the original directory
108
- cd $ROOT_DIR
108
+ cd " $ROOT_DIR "
109
109
}
110
110
111
111
trim_commit_message () {
@@ -114,7 +114,7 @@ trim_commit_message() {
114
114
# Check if the commit message contains a newline character
115
115
if [[ " $commit_message " == * $' \n ' * ]]; then
116
116
# Extract the first line of the commit message
117
- local first_line=${commit_message%% $' \n ' * }
117
+ local first_line=" ${commit_message%% $' \n ' * } "
118
118
else
119
119
# If there's no newline, use the entire commit message
120
120
local first_line=" $commit_message "
@@ -129,24 +129,24 @@ get_repo_and_branch_info "."
129
129
130
130
# Handle arguments
131
131
case " $1 " in
132
- --git-sub)
133
- # Initialize an array to hold the directories
134
- declare -a repo_dirs
135
-
136
- cd $ROOT_DIR
137
-
138
- # Find directories containing a .github folder and store them in the array, excluding the current directory
139
- while IFS= read -r dir; do
140
- # Check if the directory is not the current directory
141
- if [[ " $dir " != " ." ]]; then
142
- repo_dirs+=(" $dir " )
143
- fi
144
- done < <( find . -type d -name .github | awk -F' /[^/]*$' ' {print $1}' )
145
-
146
- # Iterate through the directories and call the function for each
147
- for dir in " ${repo_dirs[@]} " ; do
148
- get_repo_and_branch_info " $dir "
149
- done
150
- ;;
151
- * ) ;;
132
+ --git-sub)
133
+ # Initialize an array to hold the directories
134
+ declare -a repo_dirs
135
+
136
+ cd " $ROOT_DIR "
137
+
138
+ # Find directories containing a .github folder and store them in the array, excluding the current directory
139
+ while IFS= read -r dir; do
140
+ # Check if the directory is not the current directory
141
+ if [[ " $dir " != " ." ]]; then
142
+ repo_dirs+=(" $dir " )
143
+ fi
144
+ done < <( find . -type d -name .github | awk -F' /[^/]*$' ' {print $1}' )
145
+
146
+ # Iterate through the directories and call the function for each
147
+ for dir in " ${repo_dirs[@]} " ; do
148
+ get_repo_and_branch_info " $dir "
149
+ done
150
+ ;;
151
+ * ) ;;
152
152
esac
0 commit comments