mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-21 20:08:54 +00:00
format: use shfmt to format sh files.
Use shfmt to format all the sh file. https://github.com/mvdan/sh Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
@@ -91,7 +91,7 @@ install_image() {
|
||||
install_kernel() {
|
||||
go get "github.com/${project}/packaging" || true
|
||||
pushd ${GOPATH}/src/github.com/${project}/packaging >>/dev/null
|
||||
git checkout "${kata_version}-kernel-config"
|
||||
git checkout "${kata_version}-kernel-config"
|
||||
popd >>/dev/null
|
||||
pushd "${script_dir}/../kernel" >>/dev/null
|
||||
|
||||
|
@@ -88,7 +88,7 @@ tag_repos() {
|
||||
info "Creating tag ${kata_version} in all repos"
|
||||
for repo in "${repos[@]}"; do
|
||||
git clone --quiet "https://github.com/${OWNER}/${repo}.git"
|
||||
pushd "${repo}" >> /dev/null
|
||||
pushd "${repo}" >>/dev/null
|
||||
git remote set-url --push origin "git@github.com:${OWNER}/${repo}.git"
|
||||
git fetch origin --tags
|
||||
tag="$kata_version"
|
||||
@@ -99,7 +99,7 @@ tag_repos() {
|
||||
info "Creating tag ${tag} for ${repo}"
|
||||
git tag -a "${tag}" -s -m "${PROJECT} release ${tag}"
|
||||
fi
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
@@ -107,21 +107,21 @@ push_tags() {
|
||||
info "Pushing tags to repos"
|
||||
build_hub
|
||||
for repo in "${repos[@]}"; do
|
||||
pushd "${repo}" >> /dev/null
|
||||
pushd "${repo}" >>/dev/null
|
||||
tag="$kata_version"
|
||||
[[ "packaging" == "${repo}" ]] && tag="${tag}-kernel-config"
|
||||
info "Push tag ${tag} for ${repo}"
|
||||
git push origin "${tag}"
|
||||
create_github_release "${PWD}" "${tag}"
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
create_github_release(){
|
||||
create_github_release() {
|
||||
repo_dir=${1:-}
|
||||
tag=${2:-}
|
||||
[ -d "${repo_dir}" ] || die "No repository directory"
|
||||
[ -n "${tag}" ] || die "No repository directory"
|
||||
[ -d "${repo_dir}" ] || die "No repository directory"
|
||||
[ -n "${tag}" ] || die "No repository directory"
|
||||
if ! "${hub_bin}" release | grep "${tag}"; then
|
||||
info "Creating Github release"
|
||||
"${hub_bin}" -C "${repo_dir}" release create -m "${PROJECT} ${tag}" "${tag}"
|
||||
@@ -136,13 +136,13 @@ while getopts "hp" opt; do
|
||||
p) PUSH="true" ;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
subcmd=${1:-""}
|
||||
|
||||
[ -z "${subcmd}" ] && usage && exit 0
|
||||
|
||||
pushd "${tmp_dir}" >> /dev/null
|
||||
pushd "${tmp_dir}" >>/dev/null
|
||||
|
||||
case "${subcmd}" in
|
||||
status)
|
||||
@@ -167,4 +167,4 @@ tag)
|
||||
|
||||
esac
|
||||
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
|
@@ -10,10 +10,10 @@ set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
echo "Check tag_repos.sh show help"
|
||||
./release/tag_repos.sh | grep Usage
|
||||
./release/tag_repos.sh | grep Usage
|
||||
|
||||
echo "Check tag_repos.sh -h option"
|
||||
./release/tag_repos.sh -h | grep Usage
|
||||
./release/tag_repos.sh -h | grep Usage
|
||||
|
||||
echo "Check tag_repos.sh status"
|
||||
./release/tag_repos.sh status | grep runtime
|
||||
|
@@ -9,7 +9,7 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
readonly script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
readonly script_name="$(basename "${BASH_SOURCE[0]}")"
|
||||
|
||||
readonly tmp_dir=$(mktemp -t -d pr-bump.XXXX)
|
||||
@@ -19,7 +19,7 @@ GOPATH=${GOPATH:-${HOME}/go}
|
||||
|
||||
source "${script_dir}/../scripts/lib.sh"
|
||||
|
||||
cleanup (){
|
||||
cleanup() {
|
||||
[ -d "${tmp_dir}" ] && rm -rf "${tmp_dir}"
|
||||
}
|
||||
|
||||
@@ -36,8 +36,7 @@ get_changes() {
|
||||
fi
|
||||
|
||||
# list all PRs merged from $current_version to HEAD
|
||||
git log --merges "${current_version}..HEAD" | awk '/Merge pull/{getline; getline;print }' | while read pr
|
||||
do
|
||||
git log --merges "${current_version}..HEAD" | awk '/Merge pull/{getline; getline;print }' | while read pr; do
|
||||
echo "- ${pr}"
|
||||
done
|
||||
|
||||
@@ -71,7 +70,7 @@ bump_repo() {
|
||||
|
||||
git clone --quiet "${remote_github}"
|
||||
|
||||
pushd "${repo}" >> /dev/null
|
||||
pushd "${repo}" >>/dev/null
|
||||
|
||||
# All repos we build should have a VERSION file
|
||||
[ -f "VERSION" ] || die "VERSION file not found "
|
||||
@@ -79,7 +78,7 @@ bump_repo() {
|
||||
|
||||
info "Creating PR message"
|
||||
notes_file=notes.md
|
||||
cat << EOT > "${notes_file}"
|
||||
cat <<EOT >"${notes_file}"
|
||||
# Kata Containers ${new_version}
|
||||
|
||||
$(get_changes "$current_version")
|
||||
@@ -87,15 +86,15 @@ $(get_changes "$current_version")
|
||||
EOT
|
||||
|
||||
info "Updating VERSION file"
|
||||
echo "${new_version}" > VERSION
|
||||
echo "${new_version}" >VERSION
|
||||
branch="${new_version}-branch-bump"
|
||||
git checkout -b "${branch}" master
|
||||
git add -u
|
||||
info "Creating commit with new changes"
|
||||
commit_msg="$(generate_commit $new_version $current_version)"
|
||||
git commit -s -m "${commit_msg}"
|
||||
git commit -s -m "${commit_msg}"
|
||||
|
||||
if [[ "${PUSH}" == "true" ]]; then
|
||||
if [[ ${PUSH} == "true" ]]; then
|
||||
build_hub
|
||||
info "Forking remote"
|
||||
${hub_bin} fork --remote-name=fork
|
||||
@@ -103,12 +102,12 @@ EOT
|
||||
${hub_bin} push fork -f "${branch}"
|
||||
info "Create PR"
|
||||
out=""
|
||||
out=$("${hub_bin}" pull-request -F "${notes_file}" 2>&1) || echo "$out" | grep "A pull request already exists"
|
||||
out=$("${hub_bin}" pull-request -F "${notes_file}" 2>&1) || echo "$out" | grep "A pull request already exists"
|
||||
fi
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
}
|
||||
|
||||
usage(){
|
||||
usage() {
|
||||
exit_code="$1"
|
||||
cat <<EOT
|
||||
Usage:
|
||||
@@ -125,21 +124,20 @@ EOT
|
||||
exit "$exit_code"
|
||||
}
|
||||
|
||||
while getopts "hp" opt
|
||||
do
|
||||
while getopts "hp" opt; do
|
||||
case $opt in
|
||||
h) usage 0 ;;
|
||||
p) PUSH="true" ;;
|
||||
h) usage 0 ;;
|
||||
p) PUSH="true" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( $OPTIND - 1 ))
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
repo=${1:-}
|
||||
new_version=${2:-}
|
||||
[ -n "${repo}" ] || (echo "ERROR: repository not provided" && usage 1)
|
||||
[ -n "$new_version" ] || (echo "ERROR: no new version" && usage 1 )
|
||||
[ -n "$new_version" ] || (echo "ERROR: no new version" && usage 1)
|
||||
|
||||
pushd "$tmp_dir" >> /dev/null
|
||||
pushd "$tmp_dir" >>/dev/null
|
||||
bump_repo "${repo}" "${new_version}"
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
|
@@ -9,37 +9,37 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
readonly script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
out=""
|
||||
|
||||
handle_error(){
|
||||
handle_error() {
|
||||
echo "not ok"
|
||||
echo "output: ${out}"
|
||||
}
|
||||
|
||||
OK(){
|
||||
OK() {
|
||||
echo "ok"
|
||||
}
|
||||
output_should_contain(){
|
||||
output_should_contain() {
|
||||
local output="$1"
|
||||
local text_to_find="$2"
|
||||
[ -n "$output" ]
|
||||
[ -n "$text_to_find" ]
|
||||
[ -n "$output" ]
|
||||
[ -n "$text_to_find" ]
|
||||
echo "${output}" | grep "${text_to_find}"
|
||||
}
|
||||
|
||||
trap handle_error ERR
|
||||
|
||||
echo "Missing args show help"
|
||||
out=$("${script_dir}/update-repository-version.sh" 2>&1) || (($?!=0))
|
||||
echo "${out}" | grep Usage >> /dev/null
|
||||
out=$("${script_dir}/update-repository-version.sh" 2>&1) || (($? != 0))
|
||||
echo "${out}" | grep Usage >>/dev/null
|
||||
output_should_contain "${out}" "Usage"
|
||||
OK
|
||||
|
||||
echo "Missing version show help"
|
||||
out=$("${script_dir}/update-repository-version.sh" runtime 2>&1) || (($?!=0))
|
||||
echo "${out}" | grep Usage >> /dev/null
|
||||
echo "${out}" | grep "no new version">> /dev/null
|
||||
out=$("${script_dir}/update-repository-version.sh" runtime 2>&1) || (($? != 0))
|
||||
echo "${out}" | grep Usage >>/dev/null
|
||||
echo "${out}" | grep "no new version" >>/dev/null
|
||||
OK
|
||||
|
||||
echo "help option"
|
||||
|
Reference in New Issue
Block a user