bump: Do not fail is not possible to get logs

Sometimes get logs could fail, for example
when a tag does not exit, instead of fail
just log the error in the PR.

Fixes: #609

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
Jose Carlos Venegas Munoz 2019-07-03 10:07:14 -05:00
parent 212b219e9e
commit 896ed41c7f

View File

@ -25,11 +25,23 @@ cleanup() {
trap cleanup EXIT trap cleanup EXIT
handle_error() {
local exit_code="${?}"
local line_number="${1:-}"
echo "Failed at $line_number: ${BASH_COMMAND}"
exit "${exit_code}"
}
trap 'handle_error $LINENO' ERR
get_changes() { get_changes() {
local current_version=$1 local current_version=$1
[ -n "${current_version}" ] || die "current version not provided" [ -n "${current_version}" ] || die "current version not provided"
changes=$(git log --oneline "${current_version}..HEAD") || die "failed to get logs" # If for some reason there is not a tag this could fail
# better fail and write the error in the PR
if ! changes=$(git log --oneline "${current_version}..HEAD"); then
echo "failed to get logs"
fi
if [ "${changes}" == "" ]; then if [ "${changes}" == "" ]; then
echo "Version bump no changes" echo "Version bump no changes"
return return
@ -84,6 +96,11 @@ bump_repo() {
info "Updating VERSION file" info "Updating VERSION file"
echo "${new_version}" >VERSION echo "${new_version}" >VERSION
if git diff --exit-code; then
info "${repo} already in version ${new_version}"
cat VERSION
return 0
fi
info "Creating PR message" info "Creating PR message"
notes_file=notes.md notes_file=notes.md
@ -140,7 +157,6 @@ repos=(
"shim" "shim"
) )
main(){ main(){
while getopts "hp" opt; do while getopts "hp" opt; do
case $opt in case $opt in