From a74e2caafbeb49a49f542514590f720f6b215a6d Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Tue, 12 Aug 2014 16:26:42 +0000 Subject: Add yarns for checking the state of temporary build branches --- yarns/implementations.yarn | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'yarns/implementations.yarn') diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn index 8ed007b6..a28fda54 100644 --- a/yarns/implementations.yarn +++ b/yarns/implementations.yarn @@ -604,6 +604,72 @@ Generating a manifest. die "Output isn't what we expect" fi +Implementations for temporary build branch handling +--------------------------------------------------- + + IMPLEMENTS GIVEN the workspace contains no temporary build branches + build_ref_prefix=baserock/builds/ + cd "$DATADIR/workspace" + # Want to use -execdir here, but busybox find doesn't support it + find . -name .git -print | while read gitdir; do ( + cd "$(dirname "$gitdir")" + eval "$(git for-each-ref --shell \ + --format='git update-ref -d %(refname) %(objectname)' \ + "refs/heads/$build_ref_prefix")" + ); done + + IMPLEMENTS GIVEN the git server contains no temporary build branches + build_ref_prefix=refs/heads/baserock/builds/ + cd "$DATADIR/gits" + # Want to use -execdir here, but busybox find doesn't support it + find . -name .git -print | while read gitdir; do ( + cd "$(dirname "$gitdir")" + eval "$(git for-each-ref --shell \ + --format='git update-ref -d %(refname) %(objectname)' \ + "$build_ref_prefix")" + git config receive.denyCurrentBranch ignore + rm -f .git/morph-pushed-branches + mkdir -p .git/hooks + cat >.git/hooks/post-receive <<'EOF' + #!/bin/sh + touch "$GIT_DIR/hook-ever-run" + exec cat >>"$GIT_DIR/morph-pushed-branches" + EOF + chmod +x .git/hooks/post-receive + ); done + + IMPLEMENTS GIVEN we can build with local branches + sed -i -e '/push-build-branches/d' "$DATADIR/morph.conf" + + IMPLEMENTS GIVEN we must build from pushed branches + cat >>"$DATADIR/morph.conf" <<'EOF' + push-build-branches = True + EOF + + IMPLEMENTS THEN the (\S+) repository in the workspace for (\S+) has temporary build branches + build_ref_prefix=refs/heads/baserock/builds/ + cd "$DATADIR/workspace/$MATCH_2/$(slashify_colons "test:$MATCH_1")" + git for-each-ref | grep -F "$build_ref_prefix" + + IMPLEMENTS THEN the (\S+) repository in the workspace for (\S+) has no temporary build branches + build_ref_prefix=refs/heads/baserock/builds/ + cd "$DATADIR/workspace/$MATCH_2/$(slashify_colons "test:$MATCH_1")" + if git for-each-ref | grep -F "$build_ref_prefix"; then + die Did not expect repo to contain build branches + fi + + IMPLEMENTS THEN no temporary build branches were pushed to the (\S+) repository + build_ref_prefix=refs/heads/baserock/builds/ + cd "$DATADIR/gits/$MATCH_1/.git" + if test -e morph-pushed-branches && grep -F "$build_ref_prefix" morph-pushed-branches; then + die Did not expect any pushed build branches + fi + + IMPLEMENTS THEN temporary build branches were pushed to the (\S+) repository + build_ref_prefix=refs/heads/baserock/builds/ + cd "$DATADIR/gits/$MATCH_1/.git" + test -e morph-pushed-branches && grep -F "$build_ref_prefix" morph-pushed-branches + Implementation sections for building ==================================== @@ -800,6 +866,10 @@ Implementations for building systems cd "$DATADIR/workspace/$MATCH_3" run_morph build "$MATCH_1" + IMPLEMENTS WHEN the user builds (\S+) of the (\S+) (branch|tag) + cd "$DATADIR/workspace/$MATCH_2" + run_morph build "$MATCH_1" + Implementations for tarball inspection -------------------------------------- -- cgit v1.2.1