Browse Source

codium debug

master
pvincent 3 years ago
parent
commit
033ce7ecea
  1. 5
      .vscode/extensions.json
  2. 14
      .vscode/launch.json
  3. 115
      tools/semver_git_tag

5
.vscode/extensions.json

@ -1,5 +1,6 @@
{ {
"recommendations": [ "recommendations": [
"mads-hartmann.bash-ide-vscode", "mads-hartmann.bash-ide-vscode",
]
}
"rogalmic.bash-debug",
],
}

14
.vscode/launch.json

@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (simplest configuration)",
"program": "${file}"
}
]
}

115
tools/semver_git_tag

@ -1,40 +1,47 @@
#!/bin/bash #!/bin/bash
function usage {
set -euo pipefail
function usage() {
echo 'usage: --major | -M | --minor | -m | --patch | -p' echo 'usage: --major | -M | --minor | -m | --patch | -p'
exit -1
exit 1
} }
function setCommand {
function setCommand() {
#arg1 input, #arg2 return value #arg1 input, #arg2 return value
declare -n ret=$2 declare -n ret=$2
case $1 in case $1 in
-M|--major)
ret='major' ;;
-m|--minor)
ret='minor' ;;
-p|--patch)
ret='patch' ;;
*) # unknown option
echo
echo 'unknown option, quitting'
exit -1
;;
-M | --major)
ret='major'
;;
-m | --minor)
ret='minor'
;;
-p | --patch)
ret='patch'
;;
--help)
usage
;;
*) # unknown option
echo
echo 'unknown option, quitting'
echo
usage
;;
esac esac
} }
############# main ############# main
# check more than one argument
if [[ $# -gt 1 ]];then usage ;fi
# check git covered # check git covered
REPOSITORY=`git config --get remote.origin.url`
if [[ $? -ne 0 ]]; then
echo 'no remote origin defined yet, please perform: `git remote add`'
exit -1
REPOSITORY=$(git config --get remote.origin.url)
if [[ "$?" -ne 0 ]]; then
echo 'no remote origin defined yet, please perform: git remote add'
exit 1
fi fi
# check if dirty status # check if dirty status
@ -45,50 +52,42 @@ if [[ ! $changed -eq 0 ]]; then
fi fi
git remote update git remote update
pulled_needed=$(git status -s -u no| wc -l)
pulled_needed=$(git status -s -u no | wc -l)
if [[ ! $changed -eq 0 ]]; then if [[ ! $changed -eq 0 ]]; then
echo "git pull required, please do so before processing further" echo "git pull required, please do so before processing further"
exit 3 exit 3
fi fi
# check if push needed before tagging # check if push needed before tagging
push_needed=`git rev-list --branches --not --remotes |wc -l`
push_needed=$(git rev-list --branches --not --remotes | wc -l)
if [[ $push_needed -ne 0 ]]; then if [[ $push_needed -ne 0 ]]; then
echo 'git push needed'
echo 'git push needed'
git push --set-upstream origin master git push --set-upstream origin master
echo 'git push done'
echo '-------------'
echo 'git push done'
echo '-------------'
fi fi
# check latest tagged version # check latest tagged version
LAST_TAG=`git rev-list --tags --max-count=1 2>/dev/null`
LAST_TAG=$(git rev-list --tags --max-count=1 2>/dev/null)
if [[ $? -eq 0 && -n "$LAST_TAG" ]]; then if [[ $? -eq 0 && -n "$LAST_TAG" ]]; then
echo "LAST=${LAST_TAG}" echo "LAST=${LAST_TAG}"
VERSION=`git describe --tags $LAST_TAG`
VERSION=$(git describe --tags $LAST_TAG)
else else
echo 'not yet tagged!' echo 'not yet tagged!'
VERSION=0.0.0 VERSION=0.0.0
fi fi
# check belongs to git.artcode.re
#if [[ ! ("$REPOSITORY" =~ ^git@artcode.re+) ]]; then
# echo "$REPOSITORY => $VERSION"
# echo 'folder not covered by git.artcode.re, read-only'
# exit -1
#fi
# split into array # split into array
VERSION_BITS=(${VERSION//./ }) VERSION_BITS=(${VERSION//./ })
MAJOR=${VERSION_BITS[0]:=0} MAJOR=${VERSION_BITS[0]:=0}
MINOR=${VERSION_BITS[1]:=0} MINOR=${VERSION_BITS[1]:=0}
PATCH=${VERSION_BITS[2]:=0} PATCH=${VERSION_BITS[2]:=0}
REPO_NAME=`basename $REPOSITORY`
REPO_NAME=$(basename $REPOSITORY)
REPO_NAME=${REPO_NAME%.git} REPO_NAME=${REPO_NAME%.git}
if [[ $VERSION != '0.0.0' ]];then
if [[ $VERSION != '0.0.0' ]]; then
echo "LATEST VERSION of '$REPO_NAME' is '$MAJOR.$MINOR.$PATCH'" echo "LATEST VERSION of '$REPO_NAME' is '$MAJOR.$MINOR.$PATCH'"
COMMIT_ID=`git log --format="%H" -n 1`
COMMIT_ID=$(git log --format="%H" -n 1)
if [[ $COMMIT_ID == $LAST_TAG ]]; then if [[ $COMMIT_ID == $LAST_TAG ]]; then
echo "cannot tag twice the same commit id : $LAST_TAG" echo "cannot tag twice the same commit id : $LAST_TAG"
exit -1 exit -1
@ -96,7 +95,7 @@ if [[ $VERSION != '0.0.0' ]];then
fi fi
COMMAND="${1:-ask}" COMMAND="${1:-ask}"
if [[ $COMMAND == 'ask' ]];then
if [[ $COMMAND == 'ask' ]]; then
echo -n "Press 'M' for Major, 'm' for minor, 'p' for patch ? " echo -n "Press 'M' for Major, 'm' for minor, 'p' for patch ? "
read -n1 input read -n1 input
echo echo
@ -106,25 +105,24 @@ fi
setCommand $COMMAND COMMAND setCommand $COMMAND COMMAND
case $COMMAND in case $COMMAND in
"major")
let "MAJOR++"
let "MINOR=0"
let "PATCH=0"
;;
"minor")
let "MINOR++"
let "PATCH=0"
;;
"patch")
let "PATCH++"
;;
"major")
let "MAJOR++"
let "MINOR=0"
let "PATCH=0"
;;
"minor")
let "MINOR++"
let "PATCH=0"
;;
"patch")
let "PATCH++"
;;
esac esac
TAG="$MAJOR.$MINOR.$PATCH" TAG="$MAJOR.$MINOR.$PATCH"
# check if tag exists already! # check if tag exists already!
if [[ -n $(git tag -l $TAG) ]];then
if [[ -n $(git tag -l $TAG) ]]; then
echo "WARNING: ${TAG} already exists!" echo "WARNING: ${TAG} already exists!"
exit 4 exit 4
fi fi
@ -134,20 +132,19 @@ GIT_ROOT_FOLDER=$(dirname $(git rev-parse --git-dir))
if [[ -f "${GIT_ROOT_FOLDER}/package.json" ]]; then if [[ -f "${GIT_ROOT_FOLDER}/package.json" ]]; then
echo "package.json detected, version replaced with new tag <${TAG}>" echo "package.json detected, version replaced with new tag <${TAG}>"
if ! command -v jq &> /dev/null
then
if ! command -v jq &>/dev/null; then
echo 'command <jq> not found, hint: `sudo apt install jq`' echo 'command <jq> not found, hint: `sudo apt install jq`'
exit 5 exit 5
fi fi
tmp=$(mktemp) tmp=$(mktemp)
jq '.version = $TAG' --arg TAG $TAG "${GIT_ROOT_FOLDER}/package.json" > "$tmp" && mv "$tmp" "${GIT_ROOT_FOLDER}/package.json"
jq '.version = $TAG' --arg TAG $TAG "${GIT_ROOT_FOLDER}/package.json" >"$tmp" && mv "$tmp" "${GIT_ROOT_FOLDER}/package.json"
fi fi
set -e # EXITS when any error occurs set -e # EXITS when any error occurs
echo $TAG > ${GIT_ROOT_FOLDER}/.semver_git_tag
echo $TAG >${GIT_ROOT_FOLDER}/.semver_git_tag
git add ${GIT_ROOT_FOLDER}/.semver_git_tag git add ${GIT_ROOT_FOLDER}/.semver_git_tag
echo "tagging as $TAG ..." echo "tagging as $TAG ..."
git commit -am "tagged as ${TAG}" git commit -am "tagged as ${TAG}"

Loading…
Cancel
Save