You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
git clones in containers cannot fetch other branches #1929
When I look at the clone inside my container created by concourse (CC) for unit testing, I see a git config that is incorrect (or at least inflexible). The config prevents me from being able to fetch branches.
I want to use a passed-unit-tests branch in my repo-under-test and have CC rebase the passed-unit-tests branch on the tested branch. Then push the passed-unit-test branch back to origin. In this way, I can record in github that the UT passed on the tested commit.
I am unable to git fetch passed-unit-tests or any other branch other than develop.
Cause (.git/config): fetch = +refs/heads/develop:refs/remotes/origin/develop
Solution: fetch = +refs/heads/*:refs/remotes/origin/*
A snippit that works around the issue it in my bash script:
40 info "+++ Remove git origin"
41 git remote rm origin || die "git remote rm origin failed"
42
43 info "+++ Add git origin"
44 git remote add origin \
45 "https://github.com/$gh_user/cc_test_app.git" || die "Cannot add git origin"
Alternative work around, but needing to handle branches other than develop:
sed -i -- 's?fetch = +refs/heads/develop:refs/remotes/origin/develop?fetch = +refs/heads/*:refs/remotes/origin/*?g' .git/config || die "git config fix failed"
Although, when I add passed-integration-tests, passed-system-tests, passed-staging-tests, etc., the number of resources is starting to explode.
Plus, I cannot do a simple rebase if they are two different clones...not easily anyway.
All that for really for no reason...branches should be cheap in git+CC.
Still seems like a bug. Is there a reason for restricting git like this?
Two resource, one for each branch, as @srbry suggested worked with:
function commit_to_branch {
local -r br="$1"
pushd ${cc_test_app_dir} > /dev/null
# Create a branch named tested_branch from the tested commit
local -r tested_commit="$(git rev-parse HEAD)"
git branch tested_branch "$tested_commit" || die "git branch tested_branch $tested_commit failed"
popd > /dev/null
info "Commit to $br branch. Move HEAD to $tested_commit"
pushd cc-test-app-repo-passed-unit-tests > /dev/null
# Add and fetch tested_remote. Then rebase on it.
git remote add tested_remote ../cc-test-app-repo || die "git remote add tested_remote failed"
git fetch tested_remote || die "git fetch tested_remote failed"
git rebase tested_remote/tested_branch || die "git rebase tested_remote/tested_branch failed"
popd > /dev/null
}
Activity
srbry commentedon Jan 2, 2018
@sqqqrly It feels like you should use multiple resources for this. For example:
You could then have both resources as an input to your task, do some merging etc.
sqqqrly commentedon Jan 2, 2018
I could, that is a good idea.
Although, when I add passed-integration-tests, passed-system-tests, passed-staging-tests, etc., the number of resources is starting to explode.
Plus, I cannot do a simple rebase if they are two different clones...not easily anyway.
All that for really for no reason...branches should be cheap in git+CC.
Still seems like a bug. Is there a reason for restricting git like this?
sqqqrly commentedon Jan 3, 2018
Two resource, one for each branch, as @srbry suggested worked with:
bump etree tsa handlers mux clockwork goxmldsig genproto grpc