Commit 4a00a6c8 by anun

remove init env

parent 80319e86
function hasChanges() {
# old version, just track uncommited + untracked files
# test -n "$(git status -s .)"
# expect 1 to be normal so the untracked file .make-funcition will be ignored
test 0 -ne "$(git status -s . | sed -e '/.make-function/d' | wc -l)"
}
function getRelease() {
# old : use tag in release.conf
# awk -F= '/^RELEASE=/{print $2}' release.conf
# new use tag from git of the form -> 1.0.1-2-3b10c420
TAGN=$(git describe | sed -e "s/-g.*//")
TV=$(echo $TAGN | sed -e "s/-.*//")
TM=$(echo $TAGN | sed -e "s/^[^\-]*//")
if [ -z "$TM" ]
then
TM="-0"
fi
echo $TV$TM
}
function getBaseTag() {
sed -n -e "s/^tag=\(.*\)$(getRelease)\$/\1/p" release.conf
}
function getTag() {
if [ -z "$1" ] ; then
awk -F= '/^tag/{print $2}' release.conf
else
echo "$(getBaseTag)$1"
fi
}
function setRelease() {
if [ -n "$1" ] ; then
sed -i.x -e "s/^tag=.*/tag=$(getTag $1)/" release.conf
sed -i.x -e "s/^RELEASE=.*/RELEASE=$1/g" release.conf
rm -f release.conf.x
runPreTagCommand "$1"
else
echo "ERROR: missing release version parameter " >&2
return 1
fi
}
function runPreTagCommand() {
if [ -n "$1" ] ; then
COMMAND=$(sed -n -e "s/@@RELEASE@@/$1/g" -e 's/^pre_tag_command=\(.*\)/\1/p' release.conf)
if [ -n "$COMMAND" ] ; then
if ! OUTPUT=$(bash -c "$COMMAND" 2>&1) ; then echo $OUTPUT >&2 && exit 1 ; fi
fi
else
echo "ERROR: missing release version parameter " >&2
return 1
fi
}
function tagExists() {
tag=${1:-$(getTag)}
test -n "$tag" && test -n "$(git tag | grep "^$tag\$")"
}
function differsFromRelease() {
tag=$(getTag)
! tagExists $tag || test -n "$(git diff --shortstat -r $tag .)"
}
function getVersion() {
result=$(getRelease)
if hasChanges ; then
result="$result-dirty"
fi
echo $result
}
function getVersionWithHash() {
result=$(getRelease)
if differsFromRelease; then
# output only first 7 characters
# result="$result-$(git log -n 1 --format=%h .)"
# output first 8 characters
result="$result-$(git log -n 1 --format=%H . | head -c 8)"
fi
if hasChanges ; then
result="$result-dirty"
fi
echo $result
}
function nextPatchLevel() {
version=${1:-$(getRelease)}
major_and_minor=$(echo $version | cut -d. -f1,2)
patch=$(echo $version | cut -d. -f3)
version=$(printf "%s.%d" $major_and_minor $(($patch + 1)))
echo $version
}
function nextMinorLevel() {
version=${1:-$(getRelease)}
major=$(echo $version | cut -d. -f1);
minor=$(echo $version | cut -d. -f2);
version=$(printf "%d.%d.0" $major $(($minor + 1))) ;
echo $version
}
function nextMajorLevel() {
version=${1:-$(getRelease)}
major=$(echo $version | cut -d. -f1);
version=$(printf "%d.0.0" $(($major + 1)))
echo $version
}
......@@ -170,7 +170,7 @@ func NewServer(c *Config) (*Server, error) {
//Anun
if settings.InitEnv() {
// if settings.InitEnv() {
/*
dbenable:= settings.EnvBool("DB_ENABLE")
dbuser:= settings.Env("DB_USERNAME")
......@@ -226,7 +226,7 @@ server.Infof("%s", dbDisableTLS)
fmt.Fprintf(os.Stdout, "You have connected to the database successfully\n")
server.db = db
}
}
// }
return server, nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment