Browse Source

codium debug

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

3
.vscode/extensions.json

@ -1,5 +1,6 @@
{
"recommendations": [
"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}"
}
]
}

57
tools/semver_git_tag

@ -1,40 +1,47 @@
#!/bin/bash
function usage {
set -euo pipefail
function usage() {
echo 'usage: --major | -M | --minor | -m | --patch | -p'
exit -1
exit 1
}
function setCommand {
function setCommand() {
#arg1 input, #arg2 return value
declare -n ret=$2
case $1 in
-M | --major)
ret='major' ;;
ret='major'
;;
-m | --minor)
ret='minor' ;;
ret='minor'
;;
-p | --patch)
ret='patch' ;;
ret='patch'
;;
--help)
usage
;;
*) # unknown option
echo
echo 'unknown option, quitting'
exit -1
echo
usage
;;
esac
}
############# main
# check more than one argument
if [[ $# -gt 1 ]];then usage ;fi
# 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
# check if dirty status
@ -51,9 +58,8 @@ if [[ ! $changed -eq 0 ]]; then
exit 3
fi
# 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
echo 'git push needed'
git push --set-upstream origin master
@ -62,33 +68,26 @@ if [[ $push_needed -ne 0 ]]; then
fi
# 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
echo "LAST=${LAST_TAG}"
VERSION=`git describe --tags $LAST_TAG`
VERSION=$(git describe --tags $LAST_TAG)
else
echo 'not yet tagged!'
VERSION=0.0.0
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
VERSION_BITS=(${VERSION//./ })
MAJOR=${VERSION_BITS[0]:=0}
MINOR=${VERSION_BITS[1]:=0}
PATCH=${VERSION_BITS[2]:=0}
REPO_NAME=`basename $REPOSITORY`
REPO_NAME=$(basename $REPOSITORY)
REPO_NAME=${REPO_NAME%.git}
if [[ $VERSION != '0.0.0' ]]; then
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
echo "cannot tag twice the same commit id : $LAST_TAG"
exit -1
@ -120,7 +119,6 @@ case $COMMAND in
;;
esac
TAG="$MAJOR.$MINOR.$PATCH"
# check if tag exists already!
@ -134,8 +132,7 @@ GIT_ROOT_FOLDER=$(dirname $(git rev-parse --git-dir))
if [[ -f "${GIT_ROOT_FOLDER}/package.json" ]]; then
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`'
exit 5
fi

Loading…
Cancel
Save