forked from ScoDoc/ScoDoc
script getting ScoDoc version infos
This commit is contained in:
parent
225c97b6dc
commit
bdc0ad488a
50
config/get_scodoc_version.sh
Executable file
50
config/get_scodoc_version.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get version information
|
||||
# Use VERSION.py, last commit, diff, and last upstream commit date
|
||||
|
||||
|
||||
source config.sh
|
||||
source utils.sh
|
||||
|
||||
# Source code version:
|
||||
x=$(grep SCOVERSION ../VERSION.py) || terminate "can't access VERSION.py" 1
|
||||
x=${x#*\"}
|
||||
src_version=${x%\"*}
|
||||
|
||||
# last commit
|
||||
git_last_commit_hash=$(git log -1 --format=%h)
|
||||
git_last_commit_date=$(git log -1 --format=%ci)
|
||||
|
||||
git_up_commit_hash=$(git log -1 --format=%h origin/ScoDoc8)
|
||||
git_up_commit_date=$(git log -1 --format=%ci origin/ScoDoc8)
|
||||
|
||||
# Check if git has local changes
|
||||
nchanges=$(git status --porcelain | grep -c -v '^??')
|
||||
if [ "$nchanges" -gt 0 ]
|
||||
then
|
||||
has_local_changes="yes"
|
||||
else
|
||||
has_local_changes="no"
|
||||
fi
|
||||
|
||||
# Synthetic one-line version:
|
||||
sco_version="$src_version ($git_up_commit_hash) $git_up_commit_date"
|
||||
if [ "$has_local_changes" = "yes" ]
|
||||
then
|
||||
sco_version="$sco_version (modified)"
|
||||
fi
|
||||
|
||||
#
|
||||
if [ "$1" = "-s" ]
|
||||
then
|
||||
echo "$sco_version"
|
||||
else
|
||||
echo src_version: "$src_version"
|
||||
echo git_last_commit_hash: "$git_last_commit_hash"
|
||||
echo git_last_commit_date: "$git_last_commit_date"
|
||||
echo git_up_commit_hash: "$git_up_commit_hash"
|
||||
echo git_up_commit_date: "$git_up_commit_date"
|
||||
echo has_local_diffs: "$has_local_changes"
|
||||
echo sco_version: "$sco_version"
|
||||
fi
|
@ -23,10 +23,11 @@ check_uid_root() {
|
||||
}
|
||||
|
||||
terminate() {
|
||||
status=${2:-1} # default: exit 1
|
||||
echo
|
||||
echo "Erreur: $1"
|
||||
echo
|
||||
exit 1
|
||||
exit $status
|
||||
}
|
||||
|
||||
# Start/stop scodoc, using sysv or systemd
|
||||
|
Loading…
Reference in New Issue
Block a user