yocto-autobuilder-helper/scripts/buildhistory-init
Richard Purdie 621143cee4 scripts: Various buildhistory code fixes/improvements
* Remove the code disabling it
* Move to a non-shared directory by default (but still support absolute pathnames
  if wanted)
* Use shallow clones by default for speed
* Allow force pushing 'fork' mode branches

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-07-06 15:17:41 +01:00

31 lines
772 B
Bash
Executable File

#!/bin/sh
#
# Initialize Buildhistory for this branch
#
# Called with $1 - The buildhistory directory
# $2 - The remote repository url
# $3 - The remote branch name
# $4 - The remote branch name to base from
#
BUILDHISTDIR=$1
REMOTEREPO=$2
REMOTEBRANCH=$3
BASEBRANCH=$4
if [ ! -d $BUILDHISTDIR ]; then
mkdir -p $BUILDHISTDIR
git init $BUILDHISTDIR
fi
cd $BUILDHISTDIR
git checkout -b $REMOTEBRANCH
if git ls-remote --exit-code $REMOTEREPO refs/heads/$BASEBRANCH > /dev/null; then
git fetch --depth=5 $REMOTEREPO refs/heads/$BASEBRANCH:refs/remotes/$BASEBRANCH
git reset refs/remotes/$BASEBRANCH --hard
else
echo 'Initializing Repo' >> README
git add README
git commit -s -m 'Initializing Buildhistory'
fi