-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitcc
More file actions
executable file
·82 lines (66 loc) · 2.33 KB
/
gitcc
File metadata and controls
executable file
·82 lines (66 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
# Git Commit Check (gitcc)
# Version: 0.3.0
# Author: Angelos Theodorakopoulos <angtheod@gmail.com>
# Change to the directory of the script and source the required scripts.
cd "$(dirname "$0")" || exit 1
. ./config.sh
cd "$(dirname "$0")" || exit 1
. ./lib.sh
header() {
line3 "╔" "╗" $((WIDTH+8)) "═"
if [ "$COMPACT" = 0 ]; then
printf " %s${CYAN}Load\n" "$SECTION_SYMBOL"
line "Configuration" "${1:-./config.sh}"
fi
}
about() {
[ "$COMPACT" = 1 ] && return
printf "\n %s${CYAN}About\n" "$SECTION_SYMBOL"
line "$BACKEND_SYNTAX_TOOL" "$BACKEND_SYNTAX_VERSION"
line "$FRAMEWORK_TOOL" "$(extract_version "$FRAMEWORK_VERSION")"
line "$BACKEND_STANDARDS_TOOL" "$(extract_version "$BACKEND_STANDARDS_VERSION")"
line "$BACKEND_TESTS_TOOL" "$(extract_version "$BACKEND_TESTS_VERSION")"
line "$BACKEND_DEPENDENCIES_TOOL" "$(extract_version "$BACKEND_DEPENDENCIES_VERSION")"
line "$FRONTEND_DEPENDENCIES_TOOL" "$(extract_version "$FRONTEND_DEPENDENCIES_VERSION")"
line "$FRONTEND_DEPENDENCIES_TOOL_2" "$(extract_version "$FRONTEND_DEPENDENCIES_VERSION_2")"
}
footer() {
line3 "╚" "╝" $((WIDTH+8)) "═"
END=$(date +%s)
time=$((END-START))
[ $LOG_VIEWER = 1 ] && line3 "$LOG_SYMBOL $LOG_VIEWER_URL" "$TIME_SYMBOL ${time}sec" "$((WIDTH+7))" " "
}
check() {
[ "$COMPACT" = 0 ] && [ "$ENABLED" != "" ] && printf "\n %s${CYAN}Check${NC}\n" "$SECTION_SYMBOL"
[ "$LOG" = 1 ] && log info "══════════════" ""
# Directly run all scripts (without any extra logic such as contains_string).
#[ "$ENABLED" != "" ] && find "$GITCC_PATH/scripts" -type f -name '*.sh' | sort -h | xargs -L 1 -d '\n' sh;
if [ "$ENABLED" != "" ]; then
for script in $(find "$GITCC_SCRIPTS_PATH" -type f -name '*.sh' | sort); do
_name=$(basename "$script")
_id="${_name%%_*}"
# Check if the script is enabled in the configuration and then
# source the script so that it runs in the same shell process and the variables are accessible within it.
contains_string "$_id" "$ENABLED" && . "$script"
done
fi
}
init() {
START=$(date +%s)
HAS_ERRORS=0
STAGED_PHP_FILES=$(git diff --cached --name-only --diff-filter=ACMR HEAD | grep .php)
HAS_SYNTAX_ERRORS=0
}
main() {
init
header
about
check
footer
if [ "$HAS_ERRORS" -ne 0 ]; then
exit 1
fi
}
main
exit $?