change setuser mechanism
rely on the fact the LC_IDENTIFICATION (and other LC_*) environment variables are forwarded from an ssh client to the server
This commit is contained in:
19
gitea.py
19
gitea.py
@ -8,25 +8,36 @@ GITEA_URL = 'https://gitea.psi.ch/linse/%s.git'
|
|||||||
|
|
||||||
GET_GITEA_TOKEN = """#!/bin/bash
|
GET_GITEA_TOKEN = """#!/bin/bash
|
||||||
if [ -z "$GITEA_TOKEN" ]; then
|
if [ -z "$GITEA_TOKEN" ]; then
|
||||||
|
re='^([0-9a-f]{8:}) ([^ ]*) (.*)?$'
|
||||||
|
if [[ "$LC_IDENTIFICATION" =~ $re ]]; then
|
||||||
|
export GITEA_TOKEN=${BASH_REMATCH[1]}
|
||||||
|
export GIT_AUTHOR_NAME=${BASH_REMATCH[3]}
|
||||||
|
else
|
||||||
echo "" 1>&2
|
echo "" 1>&2
|
||||||
echo "you try to push without setting GITEA_TOKEN" 1>&2
|
echo "you try to push without setting GITEA_TOKEN" 1>&2
|
||||||
echo "please use 'setuser <initials>' to identify yourself" 1>&2
|
echo "please use 'setuser <user name>' to identify yourself" 1>&2
|
||||||
echo "" 1>&2
|
echo "" 1>&2
|
||||||
echo quit=1
|
echo quit=1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
if [ "$1" == "get" ]; then
|
if [ "$1" == "get" ]; then
|
||||||
echo "connecting with gitea token for $GIT_AUTHOR_NAME" 1>&2
|
echo "connecting with gitea token for $GIT_AUTHOR_NAME" 1>&2
|
||||||
fi
|
fi
|
||||||
echo username=_
|
echo "username=_"
|
||||||
echo "password=$GITEA_TOKEN"
|
echo "password=$GITEA_TOKEN"
|
||||||
fi
|
fi
|
||||||
"""
|
"""
|
||||||
|
|
||||||
PRE_COMMIT_HOOK = """#!/bin/bash
|
PRE_COMMIT_HOOK = """#!/bin/bash
|
||||||
|
re='^([0-9a-f]{8:}) ([^ ]*) (.*)?$'
|
||||||
|
if [[ "$LC_IDENTIFICATION" =~ $re ]]; then
|
||||||
|
export GIT_AUTHOR_EMAIL=${BASH_REMATCH[2]}
|
||||||
|
export GIT_AUTHOR_NAME=${BASH_REMATCH[3]}
|
||||||
|
fi
|
||||||
if [ "$GIT_AUTHOR_NAME" == "PREVENT_DEFAULT" ]; then
|
if [ "$GIT_AUTHOR_NAME" == "PREVENT_DEFAULT" ]; then
|
||||||
echo ''
|
echo ''
|
||||||
echo 'You tried to commit without specified author'
|
echo 'You try to commit without specified author'
|
||||||
echo "please execute 'setuser <initials>' to identify yourself"
|
echo "please execute 'setuser <user name>' to identify yourself"
|
||||||
echo 'or add the author with: git commit --author=<your name>'
|
echo 'or add the author with: git commit --author=<your name>'
|
||||||
echo ''
|
echo ''
|
||||||
exit 1
|
exit 1
|
||||||
|
Reference in New Issue
Block a user