Commit 211f15af authored by intrigeri's avatar intrigeri

Honor $BASE_BRANCH_GIT_COMMIT (refs: #16730)

So far we relied on a hack in our Jenkins job (set_origin_base_branch_head) to
tweak Git state in a way that git_base_branch_head gets it right. But that's
complex, fragile, and interacts badly with the refs mangling we do in
build-tails. So let's instead honor a pre-existing $BASE_BRANCH_GIT_COMMIT, so
we can drop the set_origin_base_branch_head hack from the Jenkins job.

What I'm doing here seems to have been the original intent of the work that was
done on #11972: f4a20a41 and
49c29304 have started work in this direction,
that was never finished, and $BASE_BRANCH_GIT_COMMIT was left entirely unused,
which confused me a great deal when starting to work on this.

Incidentally, this change makes $BASE_BRANCH_GIT_COMMIT behave in the same way
as $GIT_COMMIT (which is already taken from the environment if set), which
is more consistent and less confusing.

Commit c579fc97df8ea41dda67e24047cae131b2425250 in jenkins-jobs.git
sets $BASE_BRANCH_GIT_COMMIT to the commit that the base branch was in
during the first build, that we're trying to reproduce.
parent 4f1ab4f4
......@@ -370,7 +370,7 @@ task :setup_environment => ['validate_git_state'] do
end
end
ENV['BASE_BRANCH_GIT_COMMIT'] = git_helper('git_base_branch_head')
ENV['BASE_BRANCH_GIT_COMMIT'] ||= git_helper('git_base_branch_head')
['GIT_COMMIT', 'GIT_REF', 'BASE_BRANCH_GIT_COMMIT'].each do |var|
if ENV[var].empty?
raise "Variable '#{var}' is empty, which should not be possible: " +
......
......@@ -53,20 +53,19 @@ GIT_BASE_BRANCH=$(base_branch) \
if [ "${TAILS_MERGE_BASE_BRANCH:-}" = 1 ] && \
! git_on_a_tag && [ "$GIT_BRANCH" != "$GIT_BASE_BRANCH" ] ; then
GIT_BASE_BRANCH_COMMIT=$(git_base_branch_head)
[ -n "${GIT_BASE_BRANCH_COMMIT}" ] \
|| fatal "Base branch's top commit could not be guessed."
[ -n "${BASE_BRANCH_GIT_COMMIT}" ] \
|| fatal "Base branch's top commit is not set."
echo "Merging base branch origin/${GIT_BASE_BRANCH}"
echo "(at commit ${GIT_BASE_BRANCH_COMMIT})..."
echo "Merging base branch ${GIT_BASE_BRANCH}"
echo "(at commit ${BASE_BRANCH_GIT_COMMIT})..."
faketime -f "${SOURCE_DATE_FAKETIME}" \
git merge --no-edit "origin/${GIT_BASE_BRANCH}" \
git merge --no-edit "${BASE_BRANCH_GIT_COMMIT}" \
|| fatal "Failed to merge base branch."
git submodule update --init
# Adjust BUILD_BASENAME to embed the base branch name and its top commit
CLEAN_GIT_BASE_BRANCH=$(echo "$GIT_BASE_BRANCH" | sed 's,/,_,g')
GIT_BASE_BRANCH_SHORT_ID=$(git_base_branch_head --short)
GIT_BASE_BRANCH_SHORT_ID=$(git rev-parse --verify --short "${BASE_BRANCH_GIT_COMMIT}")
[ -n "${GIT_BASE_BRANCH_SHORT_ID}" ] \
|| fatal "Base branch's top commit short ID could not be guessed."
BUILD_BASENAME="${BUILD_BASENAME}+${CLEAN_GIT_BASE_BRANCH}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment