repo_tools/gpush
2023-05-18 18:40:35 -04:00

35 lines
909 B
Bash
Executable File

#!/usr/bin/env bash
if [[ -z "$1" ]]; then
project="$(basename $(pwd))"
else
project="$1"
shift
fi
token="$(pass show gitea/token/${project})"
if [[ -z "$token" ]]; then
printf 'Failed to get token for %s. ' "$project" >&2
printf 'Must be one of:\n\n' >&2
pass show gitea/token >&2
exit 1
fi
gpg_key='75D6600BEF4E8E8F'
url="https://luke:${token}@git.drheck.dev/luke/${project}.git"
if [[ "$project" == 'pass' ]]; then
pass git config user.signingkey "$gpg_key"!
pass git config commit.gpgsign true
pass git push "$url"
if [[ $? != 0 ]]; then
printf 'no upstream. setting..\n' >&2
GPG_TTY=$(tty) git push --set-upstream "$url" main
fi
else
git config user.signingkey "$gpg_key"!
git config commit.gpgsign true
GPG_TTY=$(tty) git push "$url"
if [[ $? != 0 ]]; then
printf 'no upstream. setting..\n' >&2
GPG_TTY=$(tty) git push --set-upstream "$url" main
fi
fi