summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2017-04-27 23:46:21 -0400
committerMalf Furious <m@lfurio.us>2017-04-27 23:46:21 -0400
commitd90fbde7a9805c984ef4c126f5ab58113a8488ef (patch)
tree1f2e0d8e48878a75d016ca7926bb82c273556e94
parent0fe9da0a44fc0579009364f2619e5cfd3bc900c5 (diff)
downloadsystrunk-d90fbde7a9805c984ef4c126f5ab58113a8488ef.tar.gz
systrunk-d90fbde7a9805c984ef4c126f5ab58113a8488ef.zip
Add resolvers module
-rw-r--r--resolvers.sh79
1 files changed, 79 insertions, 0 deletions
diff --git a/resolvers.sh b/resolvers.sh
new file mode 100644
index 0000000..ff4e38f
--- /dev/null
+++ b/resolvers.sh
@@ -0,0 +1,79 @@
+##
+# get_commit <version>
+#
+# Resolve a revision to a commit ID, exit via fatal error if
+# resolution cannot take place.
+##
+function get_commit
+{
+ # local repository #
+ if [[ "$remote" == "" ]]; then
+ if [[ "$1" == "HEAD" ]]; then
+ cat "$path/HEAD"
+
+ elif [[ "$1" == "BASE" ]]; then
+ cat ".systr/BASE"
+
+ elif [[ "$1" == "TRAC" ]]; then
+ cat ".systr/TRAC"
+
+ elif [[ "$1" == "NULL" ]]; then
+ echo "NULL"
+
+ elif [ -f "$path/refs/$1" ]; then
+ cat "$path/refs/$1"
+
+ elif [ -f "$path/$1/.commit.systr" ]; then
+ echo "$1"
+
+ else
+ echo "Error: $1 not a revision" >&2
+ exit
+ fi
+
+ # remote repository #
+ else
+ exit
+
+ fi
+}
+
+##
+# get_symref <version>
+#
+# Resolve a revision to a symbolic reference, exit via fatal
+# error if resolution cannot take place.
+##
+function get_symref
+{
+ # local repository #
+ if [[ "$remote" == "" ]]; then
+ if [[ "$1" == "HEAD" ]]; then
+ echo "HEAD"
+
+ elif [[ "$1" == "BASE" ]]; then
+ echo "BASE"
+
+ elif [[ "$1" == "TRAC" ]]; then
+ cat ".systr/TRAC"
+
+ elif [[ "$1" == "NULL" ]]; then
+ echo "NULL"
+
+ elif [ -f "$path/refs/$1" ]; then
+ echo "refs/$1"
+
+ elif [ -f "$path/$1/.commit.systr" ]; then
+ echo "$1"
+
+ else
+ echo "Error: $1 not a revision" >&2
+ exit
+ fi
+
+ # remote repository #
+ else
+ exit
+
+ fi
+}