aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/buildhistory-init
blob: b87af405a7fd8532c45dfcb9c1b9c3be25ced727 (plain)
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
#!/bin/sh
#
# Initialize Buildhistory for this branch
#
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright Linux Foundation, Richard Purdie
#
# 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
git tag ab-fetchrev