golang.org/x/build@v0.0.0-20240506185731-218518f32b70/cmd/coordinator/version.sh (about)

     1  #!/bin/sh
     2  
     3  # Copyright 2017 The Go Authors. All rights reserved.
     4  # Use of this source code is governed by a BSD-style
     5  # license that can be found in the LICENSE file.
     6  
     7  VERSION=$(git rev-parse HEAD)
     8  CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
     9  if ! git diff-index HEAD --quiet || ! git diff-files --quiet; then
    10    VERSION=$VERSION-dirty
    11    dirty=1
    12  fi
    13  if [ -n "$dirty" ] || [ -z "$(git config --get-all "branch.${CURRENT_BRANCH}.remote")" ] || [ -n "$(git rev-list '@{upstream}..HEAD')" ]; then
    14    # Append -user-20190509T023926
    15    VERSION=$VERSION-$USER-$(git show --quiet --pretty=%cI HEAD | perl -npe 's/[^\dT]//g;$_=substr($_,0,15)')
    16  fi
    17  echo "$VERSION"