init
This commit is contained in:
parent
6f2bd20e67
commit
498c89dc27
36
gclone
Executable file
36
gclone
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
printf 'Need a project:\n\n' >&2
|
||||||
|
pass show gitea/token >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
project="$1"
|
||||||
|
shift
|
||||||
|
token="$(pass show gitea/token/${project})"
|
||||||
|
if [[ -z "$token" ]]; then
|
||||||
|
printf 'Failed to get token.\n'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
token_url="https://luke:${token}@git.drheck.dev/luke/${project}.git"
|
||||||
|
url="https://luke@git.drheck.dev/luke/${project}.git"
|
||||||
|
|
||||||
|
if [[ "$project" == 'pass' ]]; then
|
||||||
|
if [[ -n "$@" ]]; then
|
||||||
|
pass git pull "$@" "$token_url"
|
||||||
|
else
|
||||||
|
pass git pull "token_url"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ -n "$@" ]]; then
|
||||||
|
readarray -t out <<< "$(git clone "$@" "$token_url" 2>&1)"
|
||||||
|
else
|
||||||
|
readarray -t out <<< "$(git clone "$token_url" 2>&1)"
|
||||||
|
fi
|
||||||
|
new_dir="$(awk -F\' '{print $2}' <<< "$out")"
|
||||||
|
cd "$new_dir"
|
||||||
|
git remote remove origin
|
||||||
|
git push --set-upstream "$url" main
|
||||||
|
fi
|
||||||
|
|
30
gpull
Executable file
30
gpull
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
printf 'Need a project:\n\n' >&2
|
||||||
|
pass show gitea/token >&2
|
||||||
|
exit 1
|
||||||
|
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
|
||||||
|
url="https://luke:${token}@git.drheck.dev/luke/${project}.git"
|
||||||
|
if [[ "$project" == 'pass' ]]; then
|
||||||
|
if [[ -n "$@" ]]; then
|
||||||
|
pass git pull "$@" "$url"
|
||||||
|
else
|
||||||
|
pass git pull "$url"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ -n "$@" ]]; then
|
||||||
|
git pull "$@" "$url"
|
||||||
|
else
|
||||||
|
git pull "$url"
|
||||||
|
fi
|
||||||
|
fi
|
30
gpush
Executable file
30
gpush
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
printf 'Need a project:\n\n' >&2
|
||||||
|
pass show gitea/token >&2
|
||||||
|
exit 1
|
||||||
|
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
|
||||||
|
url="https://luke:${token}@git.drheck.dev/luke/${project}.git"
|
||||||
|
if [[ "$project" == 'pass' ]]; then
|
||||||
|
if [[ -n "$@" ]]; then
|
||||||
|
pass git push "$@" "$url"
|
||||||
|
else
|
||||||
|
pass git push "$url"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ -n "$@" ]]; then
|
||||||
|
git push "$@" "$url"
|
||||||
|
else
|
||||||
|
git push "$url"
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user