Skip to content
File

Blob: tools/unix/workspace-status.sh

bash37 lines
1#!/usr/bin/env bash
2 
3# This script is hooked into bazel via the --workspace_status_command in .bazelrc. It
4# runs during each build.
5 
6script_dir=$(dirname "$0")
7inside_work_tree=$(git rev-parse --is-inside-work-tree 2>/dev/null)
8 
9# Check for issues that may affect developer workspace
10 
11# Logs an issue
12# $1 = description
13function issue_detected() {
14 let issue_count=issue_count+1
15 cat >&2 <<EOF
16Workspace issue detected #${issue_count}
17
18$1
19
20EOF
21}
22 
23# Check githooks
24GITHOOKS_MSG=$(cat<<EOF
25 It looks like the git config option core.hooksPath is not set. The workerd
26 repository uses hooks stored in githooks/ to check for common mistakes
27 and prevent production breakages.
28
29 To set up the hooks, please run:
30
31 git config core.hooksPath githooks
32EOF
33)
34if [ "${inside_work_tree}" = "true" ] && [ "$EUID" -ne 0 ] && [ -z "`git config core.hooksPath`" ]; then
35 issue_detected "${GITHOOKS_MSG}"
36fi