diff options
author | Renato Golin <renato.golin@linaro.org> | 2017-05-17 17:52:55 +0100 |
---|---|---|
committer | Renato Golin <renato.golin@linaro.org> | 2017-05-19 18:47:34 +0000 |
commit | 828aa5068299ad256db919e114495f8a0302c0d9 (patch) | |
tree | fe0ec4f7f441cad2ab55feca0910b0fa09aa39de /tcwg-llvm-common.sh | |
parent | 5e0ea6ba6e90ea92367bad28e87f033ff0fccb17 (diff) |
tcwg-llvm-*: Only clone the repos that have the specified branch
This implements the simplest way to do a pre-commit test as described in
TCWG-1124: Any tree that needs building will push to the appropriate
branch all the projects that they need, regardless of changes.
This can only work if the underlying process guarantees that:
1. No user will ever create a repo with that name, even by accident,
for example, by Forcing an exclusive namespace like
jenkins-test/username/branch.
2. The branches are deleted at the end, regardless of success or failure.
To re-start a build on the same branch, just push it again and re-run the
job. This may not be possible for Jenkins to do (as it doesn't have
write permissions to all git repos we could possibly try to build from),
so this will need some coordination with the rest of the LLVM scripts.
This change also re-factors how to checkout the llvm repositories, so
that we can control on a branch level and collect only the relevant SVN
revisions from the branches we have actually checked out.
Change-Id: I2f77ac49f23ce79f2057f1cc90e1ccd63e2a45f4
Diffstat (limited to 'tcwg-llvm-common.sh')
-rwxr-xr-x | tcwg-llvm-common.sh | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tcwg-llvm-common.sh b/tcwg-llvm-common.sh index 7eaec6db..180faa88 100755 --- a/tcwg-llvm-common.sh +++ b/tcwg-llvm-common.sh @@ -88,9 +88,12 @@ update_git() { } # Find the SVN revision of a git-svn repository +# The first commit might not be upstream in a branch +# Assuming there won't be more than 10 non-upstream +# If this becomes common, we'll have to move this logic to a perl/python script find_svn_rev() { local BASE=$1 - rev="$(git -C "$BASE" log -n 1 | grep git-svn-id | perl -pe "s/.*@(\d+)\s.*/\$1/")" + rev="$(git -C "$BASE" log -n 10 | grep git-svn-id | perl -pe "s/.*@(\d+)\s.*/\$1/")" echo "$rev" } @@ -103,6 +106,18 @@ find_last_rev() { echo "$LAST" } +# Git remote has branch +has_remote_branch() { + local REPO="$1" + local BRANCH="$2" + REF="$(git ls-remote --heads "$REPO" "$BRANCH")" + if [ -z "$REF" ]; then + return 1 + else + return 0 + fi +} + # Environment Variables and default values CPUS=$(nproc --all) # We may use between 500MB and 1GB per link job |