project-config/roles/copy-release-tools-scripts/files/release-tools/functions
manchandavishal 0cb4819d91 Retire django-openstack-auth
``django_openstack_auth`` code was merged into the main horizon
repository during the queens release. This repo is already
deprecated and now we can retire it. This patch removes all
references of ``django_openstack_auth`` as mentioned in [1].
Also, this patch takes care of step 2(End project Gating)
and and step 4(Remove Project) because
step 1(Stop requirements syncing) and step3(Remove Project Content)
is  already handled by If04778ccc99ea92355378d59e616d8794e36ea14
and I74b10a90fe79fc768cfb8de6f68d3cd2f4938e51 respectively.

Note: this patch doesn't drop the official-openstack-repo-jobs template
and noop-job because noop-job is needs to be defined for the check and
gate queues to merge a patch and official-openstack-repo-jobs is needed
to syncup the changed in github repo once Ib811fb321d18fc01f3786f8b3ab16b2eda558864
merged we can drop this template and noop-job.

[1] https://docs.openstack.org/project-team-guide/repository.html#retiring-a-repository

Change-Id: Ifa691c2d2e7ac8bb502c8fae7dbdcc89fa4ef825
2021-07-16 22:10:16 +05:30

140 lines
4.4 KiB
Bash

#!/bin/bash
#
# Shared functions for shell scripts
#
_functions_bindir=$(realpath $(dirname $0))
# Make sure custom grep options don't get in the way
unset GREP_OPTIONS
function lp_project_to_repo {
typeset proj="$1"
if [[ $proj == python-*client* ]]; then
echo $proj
elif [[ $proj == glance-store ]]; then
echo glance_store
else
# Some of the repository names don't match the launchpad names, e.g.
# python-stevedore and python-cliff.
echo $proj | sed -e 's|^python-||'
fi
}
function _cleanup_tmp {
rm -rf $MYTMPDIR
return 0
}
function setup_temp_space {
MYTMPDIR=`mktemp -d _tmp-${1}-XXX`
mkdir -p "$MYTMPDIR"
trap _cleanup_tmp EXIT
cd "$MYTMPDIR"
# NOTE(dhellmann): On some platforms mktemp returns a short name
# instead of a full path, so expand the full path by looking at
# where we ended up after the cd operation.
MYTMPDIR="$(pwd)"
}
function get_last_tag {
# Print the most recent tag for a ref. If no ref is specified, the
# currently checked out branch is examined.
local ref="$1"
if ! git describe --abbrev=0 --first-parent ${ref} >/dev/null 2>&1; then
echo ""
else
git describe --abbrev=0 --first-parent ${ref}
fi
}
function update_gitreview {
typeset branch="$1"
echo "Updating .gitreview"
git checkout $branch
# Remove a trailing newline, if present, to ensure consistent
# formatting when we add the defaultbranch line next.
typeset grcontents="$(echo -n "$(cat .gitreview | grep -v defaultbranch)")
defaultbranch=$branch"
echo "$grcontents" > .gitreview
git add .gitreview
git commit -m "Update .gitreview for $branch"
git show
local shortbranch=$(basename $branch)
git review -t "create-${shortbranch}" --yes
}
function update_upper_constraints {
typeset branch="$1"
typeset redirect_branch=$(basename $branch)
typeset uc_url="https://releases.openstack.org/constraints/upper/${redirect_branch}"
echo "Updating tox.ini for upper-constraints"
git checkout $branch
if [[ ! -f tox.ini ]]; then
echo "No tox.ini file, skipping constraints"
return 0
fi
sed -i~ -e "s,{\(env:UPPER_CONSTRAINTS_FILE\)[^ ]*},{env:TOX_CONSTRAINTS_FILE:$uc_url}," tox.ini
sed -i~ -e "s,{\(env:TOX_CONSTRAINTS_FILE\)[^ ]*},{\1:$uc_url}," tox.ini
# Octavia project specific
if [[ -f elements/amphora-agent/source-repository-amphora-agent ]]; then
sed -i~ -e "s,\(https://opendev.org/openstack/octavia\).*,\1 ${branch}," elements/amphora-agent/source-repository-amphora-agent
sed -i~ -e "s,\(file /opt/upper-constraints.txt\) \(.*\),\1 ${uc_url}," elements/amphora-agent/source-repository-amphora-agent
fi
if [[ -f elements/octavia-lib/source-repository-octavia-lib ]]; then
sed -i~ -e "s,\(https://opendev.org/openstack/octavia-lib\).*,\1 ${branch}," elements/octavia-lib/source-repository-octavia-lib
fi
if ! git diff --exit-code >/dev/null 2>&1 ; then
git add tox.ini
if [[ -f elements/amphora-agent/source-repository-amphora-agent ]]; then
git add elements/amphora-agent/source-repository-amphora-agent
fi
if [[ -f elements/octavia-lib/source-repository-octavia-lib ]]; then
git add elements/octavia-lib/source-repository-octavia-lib
fi
msg="Update TOX_CONSTRAINTS_FILE for $branch"
body="Update the URL to the upper-constraints file to point to the redirect
rule on releases.openstack.org so that anyone working on this branch
will switch to the correct upper-constraints list automatically when
the requirements repository branches.
Until the requirements repository has as $branch branch, tests will
continue to use the upper-constraints list on master."
git commit -m "$msg" -m "$body"
git show
local shortbranch=$(basename $branch)
git review -t "create-${shortbranch}" --yes
fi
}
function clone_repo {
typeset repo="$1"
typeset branch="$2"
set -e
# Sometimes we aren't given a branch, and when we aren't we don't
# want to pass the wrong arguments to clone_repo.sh.
if [ ! -z "$branch" ]; then
branch_arg="--branch"
fi
# Clone the repository using the given branch.
$_functions_bindir/clone_repo.sh $branch_arg $branch $repo
# We assume the job uses a git_config task to configure git
# properly.
git -C $repo review -s -v
}