summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@iohq.net>2015-07-26 13:52:26 -0600
committerAaron Ball <nullspoon@iohq.net>2015-07-26 13:52:26 -0600
commit086dd2e0db18886bd1a0cc4e28338871d65cbb03 (patch)
tree48dccac88a1452e238425c569c82b262401bac49
parentccd26da387165ae7533c7dd2e3fecd534de38c65 (diff)
downloadgitaccess-086dd2e0db18886bd1a0cc4e28338871d65cbb03.tar.gz
gitaccess-086dd2e0db18886bd1a0cc4e28338871d65cbb03.tar.xz
Implemented better logging and messages
Now printing repo and branch information on logs and messages. Introduced new "repo" and "branch" variables.
-rwxr-xr-xgitaccess.pre-receive16
1 files changed, 13 insertions, 3 deletions
diff --git a/gitaccess.pre-receive b/gitaccess.pre-receive
index 6231cab..2b6f0e5 100755
--- a/gitaccess.pre-receive
+++ b/gitaccess.pre-receive
@@ -44,21 +44,31 @@ function log {
echo "${d}: ${@}" >> ~/git.log
}
+# Read STDIN pre-receive arguments
+read oldrev newrev refname
+
+# Determine the branch and repo names for better logging
+branch=$(basename "${refname}")
+repo=$(basename "$(pwd)")
+
+commit_dest_str="repo '${repo}', branch '${branch}'"
+
# Check if user variable is set. Abort if it is not.
if [[ -z ${GIT_USER} ]]; then
echo "Error: Unknown ssh key. Rejecting push."
exit 1
fi
-log "Attempted login for user ${GIT_USER}"
+log "Attempted login for user ${GIT_USER} on ${commit_dest_str}"
# See if user is permitted access to this repo
grep -v '^#' users | grep ${GIT_USER} 2>&1 1>/dev/null
if [[ $? != 0 ]]; then
log "User is not permitted access to repo $(pwd)"
- echo "Error: Permission denied for user ${GIT_USER}. Aborting."
+ echo "Error: Permission denied for user ${GIT_USER} on ${commit_dest_str}."
+ echo "Aborting."
exit 1
else
- echo "User ${GIT_USER} accepted. Allowing push."
+ echo "User ${GIT_USER} accepted for ${commit_dest_str}. Allowing push."
fi

Generated by cgit