gitlab.com/gitlab-org/labkit@v1.21.0/backwards_compat.sh (about)

     1  #!/usr/bin/env sh
     2  
     3  set -eux
     4  
     5  [ -z "${1:-}" ] && (
     6  	echo "INFO: Please specify a HTTPS git URL to process."
     7  	exit 1
     8  )
     9  
    10  repo=${1}
    11  dir=${2:-}
    12  
    13  cloneDir=$(mktemp -d)
    14  
    15  CI_PROJECT_DIR=${CI_PROJECT_DIR:-$(pwd)}
    16  
    17  git clone --depth 1 "$repo" "$cloneDir"
    18  cd "$cloneDir/$dir"
    19  
    20  grep -E '^go ' go.mod
    21  
    22  go mod edit -replace=gitlab.com/gitlab-org/labkit="$CI_PROJECT_DIR"
    23  
    24  # Ensure go.mod and go.sum are up to date in the cloned repo, otherwise build may fail.
    25  go mod tidy
    26  
    27  make -j "$(nproc)"
    28  
    29  rm -rf "$cloneDir"