github.com/trevoraustin/hub@v2.2.0-preview1.0.20141105230840-96d8bfc654cc+incompatible/script/build (about)

     1  #!/usr/bin/env bash
     2  # Usage: script/build [-o output] [test]
     3  #
     4  # Sets up GOPATH and compiles hub. With `test`, runs tests instead.
     5  
     6  set -e
     7  
     8  find_source_files() {
     9    find . -maxdepth 2 -name '*.go' -not -name '*_test.go' "$@"
    10  }
    11  
    12  count_changed_files() {
    13    printf %d $(find_source_files -newer "$1" | wc -l)
    14  }
    15  
    16  up_to_date() {
    17    [ -e "$1" ] && [ "$(count_changed_files "$1")" -eq 0 ]
    18  }
    19  
    20  build_hub() {
    21    [ -n "$1" ] && (up_to_date "$1" || ./script/godep go build -o "$1" --tags noupdate)
    22  }
    23  
    24  case "$1" in
    25  "" )
    26    # always build with noupdate for now until Hub 2.0 is released
    27    build_hub hub
    28    ;;
    29  -o )
    30    shift
    31    build_hub $1
    32    ;;
    33  test )
    34    ./script/godep go test ./...
    35    ;;
    36  -h | --help )
    37    sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
    38    exit
    39    ;;
    40  * )
    41    "$0" --help >&2
    42    exit 1
    43  esac