-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
version.sh
executable file
·34 lines (26 loc) · 1.18 KB
/
version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
# Determines the currently checked-out version of Notion.
# Notion is distributed in source form through Git. Official releases are
# identified by signed tags. This script will use the git command-line tool
# to determine the version based on the latest tag and commit history.
# If the working directory is not a tag, the last tag is prepended to
# the number of commits since the last tag plus the git hash.
# If the working directory is dirty, a timestamp is appended.
# If you absolutely require a source tarball, you can use the 'Download ZIP'
# functionality. That zip will contain a directory called `notion-[xxx]`,
# where `[xxx]` denotes the tag or branch from which the tarball was derived.
# Returns 0 and prints the version on stdout on success, without newline.
# Returns a non-0 value on failure
set -e
if [ ! -z "$NOTION_RELEASE" ]; then
echo "$NOTION_RELEASE"
elif [ -e ".git" ]; then
# Git:
echo -n `git describe`
if [ ! -z "$(echo -n `git status -s`)" ]; then
echo -n `date +"+%Y%m%d-%H%M"`
fi
else
# Not git, derive name from current directory as per github naming conventions:
basename `pwd` | sed '/^notion-/!{q1}; {s/^notion-//}' | tr -d '\\n'
fi