Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dev-hooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ pre-push:
enabled: true
skip_branch_validation: false

# Django smart tests - run tests only for modified apps
django_smart_tests: true
django_test_command: "pytest -n auto"

commands:
- name: "Check CLI"
run: "venv/bin/dev-hooks --version"
25 changes: 20 additions & 5 deletions src/dev_tools_hooks/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,33 @@ yaml_get_commands() {
fi

awk -v section="$section" '
function emit() {
if (name != "" && cmd != "") {
print name "|" cmd "|" cmd_docker
name=""; cmd=""; cmd_docker=""
}
}
$0 ~ "^"section":" { in_section=1; next }
in_section && /^[a-zA-Z]/ { in_section=0 }
in_section && /^[a-zA-Z]/ { emit(); in_section=0; in_commands=0 }
in_section && /^ commands:/ { in_commands=1; next }
in_commands && /^ [a-zA-Z]/ { in_commands=0 }
in_commands && /^ [a-zA-Z]/ { emit(); in_commands=0 }
in_commands && /^ - name:/ {
emit()
gsub(/^ - name:[ ]*/, "")
gsub(/^["'\'']|["'\'']$/, "")
name=$0
}
in_commands && /^ run:/ {
gsub(/^ run:[ ]*/, "")
gsub(/^["'\'']|["'\'']$/, "")
print name "|" $0
cmd=$0
}
in_commands && /^ docker:/ {
gsub(/^ docker:[ ]*/, "")
gsub(/^["'\'']|["'\'']$/, "")
cmd_docker=$0
}
END { emit() }
' "$file"
}

Expand Down Expand Up @@ -240,14 +253,16 @@ run_commands() {
[ -z "$line" ] && continue

local name="${line%%|*}"
local cmd="${line#*|}"
local rest="${line#*|}"
local cmd="${rest%%|*}"
local cmd_docker="${rest##*|}"

echo -e "${BLUE}▶${NC} ${WHITE}${BOLD}${name}${NC}"
echo -e " ${DIM}${cmd}${NC}"

local full_cmd="$cmd"

if [ "$docker_enabled" = "true" ]; then
if [ "$docker_enabled" = "true" ] && [ "$cmd_docker" != "false" ]; then
if [ "$docker_compose" = "true" ]; then
full_cmd="docker-compose -f $compose_file exec -T $docker_container $cmd"
else
Expand Down
25 changes: 20 additions & 5 deletions src/dev_tools_hooks/hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,33 @@ yaml_get_commands() {
fi

awk '
function emit() {
if (name != "" && cmd != "") {
print name "|" cmd "|" cmd_docker
name=""; cmd=""; cmd_docker=""
}
}
/^pre-push:/ { in_prepush=1; next }
in_prepush && /^[a-zA-Z]/ { in_prepush=0 }
in_prepush && /^[a-zA-Z]/ { emit(); in_prepush=0; in_commands=0 }
in_prepush && /^ commands:/ { in_commands=1; next }
in_commands && /^ [a-zA-Z]/ { in_commands=0 }
in_commands && /^ [a-zA-Z]/ { emit(); in_commands=0 }
in_commands && /^ - name:/ {
emit()
gsub(/^ - name:[ ]*/, "")
gsub(/^["'\'']|["'\'']$/, "")
name=$0
}
in_commands && /^ run:/ {
gsub(/^ run:[ ]*/, "")
gsub(/^["'\'']|["'\'']$/, "")
print name "|" $0
cmd=$0
}
in_commands && /^ docker:/ {
gsub(/^ docker:[ ]*/, "")
gsub(/^["'\'']|["'\'']$/, "")
cmd_docker=$0
}
END { emit() }
' "$file"
}

Expand Down Expand Up @@ -374,14 +387,16 @@ run_commands() {
[ -z "$line" ] && continue

local name="${line%%|*}"
local cmd="${line#*|}"
local rest="${line#*|}"
local cmd="${rest%%|*}"
local cmd_docker="${rest##*|}"

echo -e "${BLUE}▶${NC} ${WHITE}${BOLD}${name}${NC}"
echo -e " ${DIM}${cmd}${NC}"

local full_cmd="$cmd"

if [ "$docker_enabled" = "true" ]; then
if [ "$docker_enabled" = "true" ] && [ "$cmd_docker" != "false" ]; then
if [ "$docker_compose" = "true" ]; then
full_cmd="docker-compose -f $compose_file exec -T $docker_container $cmd"
else
Expand Down
Loading