File: github-sha.sh

package info (click to toggle)
metview 5.26.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 614,356 kB
  • sloc: cpp: 560,586; ansic: 44,641; xml: 19,933; f90: 17,984; sh: 7,454; python: 5,565; yacc: 2,318; lex: 1,372; perl: 701; makefile: 88
file content (37 lines) | stat: -rwxr-xr-x 950 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash

owner=$1
repo=$2
branch=$3

if [ -z "${TMPDIR}" ]; then
  TMPDIR=${HOME}/tmp
fi
SOURCE_DIR=${TMPDIR}/check-git-${repo}

dump_output() {
   echo " ++ Tailing the last 500 lines of output from ${BUILD_OUTPUT}"
   tail -500 ${BUILD_OUTPUT}
}
error_handler() {
  echo ERROR: An error was encountered with the build.
  rm -rf ${SOURCE_DIR}
  dump_output
  exit 1
}
# If an error occurs, run our error handler to output a tail of the build
trap 'error_handler' ERR

BUILD_OUTPUT=${TMPDIR}/tmp-${repo}.log

mkdir -p ${TMPDIR}
touch $BUILD_OUTPUT
pushd . >> ${BUILD_OUTPUT} 2>&1
#git clone --depth=1 -b ${branch} https://github.com/${owner}/${repo} ${SOURCE_DIR} >> ${BUILD_OUTPUT} 2>&1 
git clone https://github.com/${owner}/${repo} ${SOURCE_DIR} >> ${BUILD_OUTPUT} 2>&1
cd ${SOURCE_DIR} >> ${BUILD_OUTPUT} 2>&1 
git checkout ${branch} >> ${BUILD_OUTPUT} 2>&1 
git rev-parse HEAD
cd ..
rm -rf ${SOURCE_DIR}
popd >> ${BUILD_OUTPUT} 2>&1