2025.08.20 17:02:19 (laptop1.cmoser.eu)

This commit is contained in:
Christian Moser 2025-08-20 17:02:19 +02:00
parent 4bc0615154
commit de8e04cbf9
Failed to extract signature

236
git.sh
View File

@ -1,130 +1,130 @@
# vim: syn=sh ts=4 sts=4 sw=4 smartindent autoindent expandtab ff=unix
git-initialize() {
USAGE="git-initialize -u USER -e EMAIL [-b DEFAULT_BRANCH] [-S SSH_KEY] [-s SSH_COMMAND]"
args=$( getopt "b:e:s:S:u:" $* )
if [ $? -ne 0 ]; then
echo "$USAGE"
return 2
fi
#git-initialize() {
# USAGE="git-initialize -u USER -e EMAIL [-b DEFAULT_BRANCH] [-S SSH_KEY] [-s SSH_COMMAND]"
# args=$( getopt "b:e:s:S:u:" $* )
# if [ $? -ne 0 ]; then
# echo "$USAGE"
# return 2
# fi
local default_branch=main
local user="$USER"
local email=""
local ssh_key=""
local ssh_command=""
# local default_branch=main
# local user="$USER"
# local email=""
# local ssh_key=""
# local ssh_command=""
set -- $args
while :; do
case "$1" in
-b)
local default_branch="$2"
shift; shift
;;
-e)
local email="$2"
shift; shift
;;
-S)
local ssh_key="$2"
shift; shift
;;
-s)
local ssh_command="$2"
shift; shift
;;
-u)
local user="$2"
shift; shift
;;
--)
shift; break
;;
esac
done
# set -- $args
# while :; do
# case "$1" in
# -b)
# local default_branch="$2"
# shift; shift
# ;;
# -e)
# local email="$2"
# shift; shift
# ;;
# -S)
# local ssh_key="$2"
# shift; shift
# ;;
# -s)
# local ssh_command="$2"
# shift; shift
# ;;
# -u)
# local user="$2"
# shift; shift
# ;;
# --)
# shift; break
# ;;
# esac
# done
if [ -z "$email" ]; then
read -p "Email: " __git_email__
local email=$__git_email__
unset __git_email__
fi
# if [ -z "$email" ]; then
# read -p "Email: " __git_email__
# local email=$__git_email__
# unset __git_email__
# fi
signingkey=$( gpgsm --list-secret-keys | egrep '(key usage|ID)' | grep -v CertifyID |grep -B 1 digitalSignature | awk '/ID/ {print $2}' )
# signingkey=$( gpgsm --list-secret-keys | egrep '(key usage|ID)' | grep -v CertifyID |grep -B 1 digitalSignature | awk '/ID/ {print $2}' )
git config --global user.name "$user"
git config --global user.email "$email"
git config --global init.defaultBranch "$default_branch"
if [ -n "$ssh_command" ]; then
git config --global core.sshCommand "$ssh_command"
elif [ -n "$ssh_key" ]; then
git config --global core.sshCommand "ssh -i \"$ssh_key\""
fi
}
# git config --global user.name "$user"
# git config --global user.email "$email"
# git config --global init.defaultBranch "$default_branch"
# if [ -n "$ssh_command" ]; then
# git config --global core.sshCommand "$ssh_command"
# elif [ -n "$ssh_key" ]; then
# git config --global core.sshCommand "ssh -i \"$ssh_key\""
# fi
#}
git-init-smime() {
USAGE="git-init-smime [-cgh] CERT_ID"
#git-init-smime() {
# USAGE="git-init-smime [-cgh] CERT_ID"
args=$( getopt "cCgh" $* )
if [ $? -ne 0 ]; then
echo $USAGE
return 2
fi
set -- $args
local sign_commits=""
local global=""
while :; do
case "$1" in
-C)
local sign_commits=NO
shift
;;
-c)
local sign_commits=YES
shift
;;
-g)
local global="--global"
shift
;;
-h)
cat << EOF
git-init-smime HELP
SYNOPSIS
$USAGE
OPTIONS
-C Disable automatic signing of commits.
[DEFAULT: no change]
-c Enable automatic signing of commits.
[DEFAULT: no change]
-g Set global GIT options.
-h Print this help message and exit.
EOF
shift; return
;;
--)
shift; break
;;
esac
done
if [ -z "$1" ]; then
echo "No CERT_ID given! Obtain the ID with \"gpgsm --list-secret-keys\"" >&2
echo "$USAGE"
return 2
fi
git config $global user.signingkey "$1"
git config $global gpg.format x509
if [ "$sign_commits" = "YES" ]; then
git config $global commit.gpgsign true
elif [ "$sign_commits" = "NO" ]; then
git config $global commit.gpgsign false
fi
}
# args=$( getopt "cCgh" $* )
# if [ $? -ne 0 ]; then
# echo $USAGE
# return 2
# fi
# set -- $args
#
# local sign_commits=""
# local global=""
#
# while :; do
# case "$1" in
# -C)
# local sign_commits=NO
# shift
# ;;
# -c)
# local sign_commits=YES
# shift
# ;;
# -g)
# local global="--global"
# shift
# ;;
# -h)
# cat << EOF
#git-init-smime HELP
#
#SYNOPSIS
# $USAGE
#
#OPTIONS
# -C Disable automatic signing of commits.
# [DEFAULT: no change]
# -c Enable automatic signing of commits.
# [DEFAULT: no change]
# -g Set global GIT options.
# -h Print this help message and exit.
#EOF
# shift; return
# ;;
# --)
# shift; break
# ;;
# esac
# done
#
# if [ -z "$1" ]; then
# echo "No CERT_ID given! Obtain the ID with \"gpgsm --list-secret-keys\"" >&2
# echo "$USAGE"
# return 2
# fi
#
# git config $global user.signingkey "$1"
# git config $global gpg.format x509
# if [ "$sign_commits" = "YES" ]; then
# git config $global commit.gpgsign true
# elif [ "$sign_commits" = "NO" ]; then
# git config $global commit.gpgsign false
# fi
#}
git-init-gpg() {
echo TODO