Skip to content

Commit 23cd049

Browse files
committed
Refactor
1 parent d2740ab commit 23cd049

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

githublint.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ source "logging.sh"
3232
sources="$(mktemp)"
3333
find "$LIB_DIR" -path "$LIB_DIR/reporter/*.sh" -o -path "$LIB_DIR/rules/*.sh" | while read -r file
3434
do
35-
echo source "$file" "$LIB_DIR"
35+
echo source "$file"
3636
done > "$sources"
3737
# shellcheck source=/dev/null
3838
source "$sources"
@@ -65,6 +65,8 @@ function usage() {
6565
}
6666

6767
function main() {
68+
trap finally EXIT
69+
6870
local profile_dir
6971
profile_dir="$HOME/.githublint/$(echo "$GITHUB_TOKEN" | md5sum | cut -d' ' -f1)"
7072
readonly PROFILE_DIR="$profile_dir"
@@ -179,7 +181,7 @@ function main() {
179181
json_seq::new "$org_dump" "$rules_dump" "$results_dump"
180182
} 6>> "$lock_file"
181183

182-
function count_running_jobs() {
184+
function process::count_running_jobs() {
183185
jobs -pr | wc -l
184186
}
185187

@@ -192,12 +194,12 @@ function main() {
192194
while IFS= read -r repo
193195
do
194196
local progress_rate=$(( ++count * 100 / num_of_repos ))
195-
logging::debug 'Running %d jobs ...' "$(count_running_jobs)"
196-
while [ "$PARALLELISM" -gt 0 ] && [ "$(count_running_jobs)" -gt "$PARALLELISM" ]
197+
logging::debug 'Running %d jobs ...' "$(process::count_running_jobs)"
198+
while [ "$PARALLELISM" -gt 0 ] && [ "$(process::count_running_jobs)" -gt "$PARALLELISM" ]
197199
do
198-
logging::debug 'Wait (running %d jobs).' "$(count_running_jobs)"
200+
logging::debug 'Wait (running %d jobs).' "$(process::count_running_jobs)"
199201
sleep .5
200-
logging::debug 'Resume (running %d jobs).' "$(count_running_jobs)"
202+
logging::debug 'Resume (running %d jobs).' "$(process::count_running_jobs)"
201203
done
202204
{
203205
local full_name
@@ -247,6 +249,5 @@ function finally () {
247249
LOG_ASYNC='' logging::debug 'command exited with status %d' $?
248250
rm -f "$CURLRC"
249251
}
250-
trap finally EXIT
251252

252253
main "$@"

0 commit comments

Comments
 (0)