by timeattack · 6y ago · 0 comments
local date=$(git log -1 --format="%cd" --date=short | sed s/-//g)
local count=$(git rev-list --count HEAD)
local commit=$(git rev-parse --short HEAD)
echo "$date.${count}_$commit"
Example result: 20191121.68_84f90ff
It provides user about general information about when program was updated along with specific information for developer for bug reporting. Also, it allows intraday releases. printf "%s.%03d_%s\n" $date $count $commit(This is for software that does not do updates to old releases. If you do updates to old releases, you need an additional version number component for that.)
main() {
local count=$(git rev-list --count HEAD)
echo $count
foo
}
foo() {
echo $count
}
main
prints:2282 2282