Skip to content

Commit

Permalink
Support version without a Git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
frno7 committed Apr 21, 2022
1 parent ba7c405 commit 471a8cf
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions script/version
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
#!/bin/sh
#!/bin/bash

set -e
set -o pipefail

if [ -f version ]
then
ver="$(cat version)"
elif [ -d .git ]
then
mod=$([ -z "$(git status -suno)" ] || echo "+")
tag="$(git describe --always --tags)"
ver="$(echo "$tag" | sed 's/^v//')$mod"
else
ver="-"
fi

if [ $# = 0 ]
then
echo "$ver"
exit
fi

[ $# = 1 ]
f="$1"

mod=$([ -z "$(git status -suno)" ] || echo "+")
tag="$(git describe --always --tags)"
ver="$(echo "$tag" | sed 's/^v//')$mod"
src=$(echo "#include "'"'"iopmod/version.h"'"'"
const char *program_version(void) { return "'"'"$ver"'"'"; }")
Expand Down

0 comments on commit 471a8cf

Please sign in to comment.