chore: create_release check for unused lint
This commit is contained in:
+36
-26
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# rust create_release
|
||||
# v0.3.1
|
||||
# v0.4.1
|
||||
|
||||
STAR_LINE='****************************************'
|
||||
CWD=$(pwd)
|
||||
@@ -12,10 +12,9 @@ YELLOW='\033[0;33m'
|
||||
PURPLE='\033[0;35m'
|
||||
RESET='\033[0m'
|
||||
|
||||
|
||||
# $1 string - error message
|
||||
error_close() {
|
||||
echo -e "\n${RED}ERROR - EXITED: ${YELLOW}$1${RESET}\n";
|
||||
echo -e "\n${RED}ERROR - EXITED: ${YELLOW}$1${RESET}\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -56,8 +55,7 @@ get_git_remote_url() {
|
||||
# Check that git status is clean
|
||||
check_git_clean() {
|
||||
GIT_CLEAN=$(git status --porcelain)
|
||||
if [[ -n $GIT_CLEAN ]]
|
||||
then
|
||||
if [[ -n $GIT_CLEAN ]]; then
|
||||
error_close "git dirty"
|
||||
fi
|
||||
}
|
||||
@@ -66,8 +64,7 @@ check_git_clean() {
|
||||
check_git() {
|
||||
CURRENT_GIT_BRANCH=$(git branch --show-current)
|
||||
check_git_clean
|
||||
if [[ ! "$CURRENT_GIT_BRANCH" =~ ^dev$ ]]
|
||||
then
|
||||
if [[ ! "$CURRENT_GIT_BRANCH" =~ ^dev$ ]]; then
|
||||
error_close "not on dev branch"
|
||||
fi
|
||||
}
|
||||
@@ -79,8 +76,7 @@ ask_changelog_update() {
|
||||
printf "%s" "$RELEASE_BODY_TEXT"
|
||||
printf "\n%s\n" "${STAR_LINE}"
|
||||
ask_yn "accept release body"
|
||||
if [[ "$(user_input)" =~ ^y$ ]]
|
||||
then
|
||||
if [[ "$(user_input)" =~ ^y$ ]]; then
|
||||
update_release_body_and_changelog "$RELEASE_BODY_TEXT"
|
||||
else
|
||||
exit
|
||||
@@ -122,8 +118,7 @@ check_tag () {
|
||||
LATEST_TAG=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
||||
echo -e "\nCurrent tag: ${PURPLE}${LATEST_TAG}${RESET}\n"
|
||||
echo -e "${YELLOW}Choose new tag version:${RESET}\n"
|
||||
if [[ $LATEST_TAG =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]
|
||||
then
|
||||
if [[ $LATEST_TAG =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
|
||||
IFS="." read -r MAJOR MINOR PATCH <<<"${LATEST_TAG:1}"
|
||||
else
|
||||
MAJOR="0"
|
||||
@@ -134,23 +129,26 @@ check_tag () {
|
||||
OP_MINOR="minor___v$(update_minor)"
|
||||
OP_PATCH="patch___v$(update_patch)"
|
||||
OPTIONS=("$OP_MAJOR" "$OP_MINOR" "$OP_PATCH")
|
||||
select choice in "${OPTIONS[@]}"
|
||||
do
|
||||
select choice in "${OPTIONS[@]}"; do
|
||||
case $choice in
|
||||
"$OP_MAJOR")
|
||||
MAJOR=$((MAJOR + 1))
|
||||
MINOR=0
|
||||
PATCH=0
|
||||
break;;
|
||||
break
|
||||
;;
|
||||
"$OP_MINOR")
|
||||
MINOR=$((MINOR + 1))
|
||||
PATCH=0
|
||||
break;;
|
||||
break
|
||||
;;
|
||||
"$OP_PATCH")
|
||||
PATCH=$((PATCH + 1))
|
||||
break;;
|
||||
break
|
||||
;;
|
||||
*)
|
||||
error_close "invalid option $REPLY"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
@@ -158,8 +156,7 @@ check_tag () {
|
||||
# ask continue, or quit
|
||||
ask_continue() {
|
||||
ask_yn "continue"
|
||||
if [[ ! "$(user_input)" =~ ^y$ ]]
|
||||
then
|
||||
if [[ ! "$(user_input)" =~ ^y$ ]]; then
|
||||
exit
|
||||
fi
|
||||
}
|
||||
@@ -199,7 +196,6 @@ cargo_build () {
|
||||
cargo_clean
|
||||
}
|
||||
|
||||
|
||||
# $1 text to colourise
|
||||
release_continue() {
|
||||
echo -e "\n${PURPLE}$1${RESET}"
|
||||
@@ -218,8 +214,20 @@ check_typos () {
|
||||
ask_continue
|
||||
}
|
||||
|
||||
# Make sure the unused lint isn't used
|
||||
check_allow_unsued() {
|
||||
matches_any=$(find . -type d \( -name .git -o -name target \) -prune -o -type f -exec grep -lE '^#!\[allow\(unused\)\]$' {} +)
|
||||
matches_cargo=$(grep "^unused = \"allow\"" ./Cargo.toml)
|
||||
if [ -n "$matches_any" ]; then
|
||||
error_close "\"#[allow(unused)]\" in ${matches_any}"
|
||||
elif [ -n "$matches_cargo" ]; then
|
||||
error_close "\"unsed = \"allow\"\" in Cargo.toml"
|
||||
fi
|
||||
}
|
||||
|
||||
# Full flow to create a new release
|
||||
release_flow() {
|
||||
check_allow_unsued
|
||||
check_typos
|
||||
|
||||
check_git
|
||||
@@ -283,7 +291,6 @@ release_flow() {
|
||||
git branch -d "$RELEASE_BRANCH"
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
cmd=(dialog --backtitle "Choose option" --radiolist "choose" 14 80 16)
|
||||
options=(
|
||||
@@ -297,22 +304,25 @@ main() {
|
||||
if [ $exitStatus -ne 0 ]; then
|
||||
exit
|
||||
fi
|
||||
for choice in $choices
|
||||
do
|
||||
for choice in $choices; do
|
||||
case $choice in
|
||||
0)
|
||||
exit;;
|
||||
exit
|
||||
;;
|
||||
1)
|
||||
cargo_test
|
||||
main
|
||||
break;;
|
||||
break
|
||||
;;
|
||||
2)
|
||||
release_flow
|
||||
break;;
|
||||
break
|
||||
;;
|
||||
3)
|
||||
cargo_build
|
||||
main
|
||||
break;;
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user