summaryrefslogtreecommitdiff
path: root/pbs-plumb-shlib
diff options
context:
space:
mode:
Diffstat (limited to 'pbs-plumb-shlib')
-rw-r--r--pbs-plumb-shlib16
1 files changed, 12 insertions, 4 deletions
diff --git a/pbs-plumb-shlib b/pbs-plumb-shlib
index ccbdffb..ded9825 100644
--- a/pbs-plumb-shlib
+++ b/pbs-plumb-shlib
@@ -4,28 +4,36 @@
# "Primitive" git functions ##########################################
+# Usage: in_git
+# Returns 0 if somewhere in a git repository, nonzero if not.
in_git() {
git rev-parse --git-dir &>/dev/null
}
+# Usage: gitdir
+# Prints the .git directory for the repository we're in
gitdir() {
git rev-parse --git-dir
}
+# Usage: gitroot
+# Prints the root directory of the git checkout
gitroot() {
git rev-parse --show-toplevel
}
+# Usage: gitbranch
+# Prints the current git branch
gitbranch() {
git rev-parse --abbrev-ref HEAD
}
+# Usage: have_file $file
+# Returns 0 if `$(gitroot)/$file` exists.
have_file() {
local file=$1
- if in_git; then
- if [[ -f "$(gitroot)/$file" ]]; then
- return 0;
- fi
+ if in_git && [[ -f "$(gitroot)/$file" ]]; then
+ return 0;
fi
return 1
}