detect project from leaf dir if no project specified

This commit is contained in:
LuKe Tidd 2022-11-18 16:45:01 -05:00
parent b9ab70213c
commit 2bf4e928dd
Signed by: luke
GPG Key ID: 75D6600BEF4E8E8F
3 changed files with 29 additions and 27 deletions

6
gclone
View File

@ -8,9 +8,12 @@ fi
project="$1" project="$1"
shift shift
token="$(pass show gitea/token/${project})" token="$(pass show gitea/token/${project})"
if [[ -z "$token" ]]; then if [[ -z "$token" ]]; then
printf 'Failed to get token.\n' printf 'Failed to get token for %s. ' "$project" >&2
print 'Must be one of:\n\n' "$project" >&2
pass show gitea/token >&2
exit 1 exit 1
fi fi
token_url="https://luke:${token}@git.drheck.dev/luke/${project}.git" token_url="https://luke:${token}@git.drheck.dev/luke/${project}.git"
@ -37,4 +40,3 @@ else
git remote remove origin git remote remove origin
git push --set-upstream "$url" main git push --set-upstream "$url" main
fi fi

22
gpull
View File

@ -1,31 +1,31 @@
#!/bin/bash #!/bin/bash
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
printf 'Need a project:\n\n' >&2 project="$(basename $(pwd))"
pass show gitea/token >&2 else
exit 1
fi
gpg_key='75D6600BEF4E8E8F'
git config user.signingkey "$gpg_key"!
git config commit.gpgsign true
project="$1" project="$1"
shift shift
unset token fi
token="$(pass show gitea/token/${project})" token="$(pass show gitea/token/${project})"
if [[ -z "$token" ]]; then if [[ -z "$token" ]]; then
printf 'Failed to get token.\n' printf 'Failed to get token for %s. ' "$project" >&2
print 'Must be one of:\n\n' "$project" >&2
pass show gitea/token >&2
exit 1 exit 1
fi fi
url="https://luke:${token}@git.drheck.dev/luke/${project}.git" url="https://luke:${token}@git.drheck.dev/luke/${project}.git"
if [[ "$project" == 'pass' ]]; then if [[ "$project" == 'pass' ]]; then
pass git config user.signingkey "$gpg_key"!
pass git config commit.gpgsign true
if [[ -n "$@" ]]; then if [[ -n "$@" ]]; then
pass git pull "$@" "$url" pass git pull "$@" "$url"
else else
pass git pull "$url" pass git pull "$url"
fi fi
else else
gpg_key='75D6600BEF4E8E8F'
git config user.signingkey "$gpg_key"!
git config commit.gpgsign true
if [[ -n "$@" ]]; then if [[ -n "$@" ]]; then
git pull "$@" "$url" git pull "$@" "$url"
else else

26
gpush
View File

@ -1,31 +1,31 @@
#!/bin/bash #!/bin/bash
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
printf 'Need a project:\n\n' >&2 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
print 'Must be one of:\n\n' "$project" >&2
pass show gitea/token >&2 pass show gitea/token >&2
exit 1 exit 1
fi fi
project="$1"
shift
unset token
token="$(pass show gitea/token/${project})"
if [[ -z "$token" ]]; then
printf 'Failed to get token.\n'
exit 1
fi
gpg_key='75D6600BEF4E8E8F' gpg_key='75D6600BEF4E8E8F'
git config user.signingkey "$gpg_key"!
git config commit.gpgsign true
url="https://luke:${token}@git.drheck.dev/luke/${project}.git" url="https://luke:${token}@git.drheck.dev/luke/${project}.git"
if [[ "$project" == 'pass' ]]; then if [[ "$project" == 'pass' ]]; then
pass git config user.signingkey "$gpg_key"!
pass git config commit.gpgsign true
if [[ -n "$@" ]]; then if [[ -n "$@" ]]; then
pass git push "$@" "$url" pass git push "$@" "$url"
else else
pass git push "$url" pass git push "$url"
fi fi
else else
git config user.signingkey "$gpg_key"!
git config commit.gpgsign true
if [[ -n "$@" ]]; then if [[ -n "$@" ]]; then
git push "$@" "$url" git push "$@" "$url"
else else