repoctl: cosmetic
This commit is contained in:
parent
87b8d5b5b0
commit
f7d036a60f
26
repoctl
26
repoctl
|
@ -144,14 +144,16 @@ function create_action() {
|
|||
esac
|
||||
}
|
||||
function gogs_create_action() {
|
||||
local url desc payload result
|
||||
local url repourl desc payload result
|
||||
local -a vars
|
||||
if [ -n "$user" -a "$user" != "$gogs_user" ]; then
|
||||
# lister les dépôts d'une organisation
|
||||
url="$gogs_url/api/v1/orgs/$user/repos"
|
||||
repourl="$gogs_url/$user/$path"
|
||||
else
|
||||
# lister les dépôts accessibles par l'utilisateur
|
||||
url="$gogs_url/api/v1/user/repos"
|
||||
repourl="$gogs_url/$gogs_user/$path"
|
||||
fi
|
||||
vars=(name="$path" private=true)
|
||||
[ -n "$1" ] && vars+=(description="$1"); shift
|
||||
|
@ -165,6 +167,7 @@ function gogs_create_action() {
|
|||
url: $url
|
||||
payload: $payload
|
||||
result: $result"
|
||||
isatty && estep "Création du dépôt $repourl"
|
||||
echo "$result" | json_get "${vars[@]}"
|
||||
}
|
||||
|
||||
|
@ -190,6 +193,7 @@ function gogs_list_action() {
|
|||
# lister les dépôts accessibles par l'utilisateur
|
||||
url="$gogs_url/api/v1/user/repos"
|
||||
fi
|
||||
|
||||
[ $# -gt 0 ] && vars=("$@") || vars=(full_name)
|
||||
setx result=curlto "$url" "" "" \
|
||||
-H 'Content-Type: application/json' \
|
||||
|
@ -213,9 +217,10 @@ function get_action() {
|
|||
esac
|
||||
}
|
||||
function gogs_get_action() {
|
||||
local url payload result
|
||||
local url repourl payload result
|
||||
local -a vars
|
||||
url="$gogs_url/api/v1/repos/$user/$path"
|
||||
repourl="$gogs_url/$user/$path"
|
||||
setx payload=json_build owner="$user" repo="$path"
|
||||
|
||||
[ $# -gt 0 ] && vars=("$@") || vars=("")
|
||||
|
@ -227,6 +232,7 @@ function gogs_get_action() {
|
|||
url: $url
|
||||
payload: $payload
|
||||
result: $result"
|
||||
isatty && estep "Attributs du dépôt $repourl"
|
||||
echo "$result" | json_get "${vars[@]}"
|
||||
}
|
||||
|
||||
|
@ -243,9 +249,10 @@ function edit_action() {
|
|||
esac
|
||||
}
|
||||
function gogs_edit_action() {
|
||||
local url payload result
|
||||
local url repourl payload result
|
||||
local -a vars
|
||||
url="$gogs_url/api/v1/repos/$user/$path"
|
||||
repourl="$gogs_url/$user/$path"
|
||||
vars=(owner="$user" repo="$path")
|
||||
while [[ "$1" == *=* ]]; do
|
||||
vars+=("$1")
|
||||
|
@ -262,6 +269,7 @@ function gogs_edit_action() {
|
|||
url: $url
|
||||
payload: $payload
|
||||
result: $result"
|
||||
isatty && estep "Mise à jour du dépôt $repourl"
|
||||
echo "$result" | json_get "${vars[@]}"
|
||||
}
|
||||
|
||||
|
@ -278,9 +286,11 @@ function delete_action() {
|
|||
esac
|
||||
}
|
||||
function gogs_delete_action() {
|
||||
local url payload result
|
||||
setx payload=json_build owner="$user" repo="$path"
|
||||
local url repourl payload result
|
||||
url="$gogs_url/api/v1/repos/$user/$path"
|
||||
repourl="$gogs_url/$user/$path"
|
||||
setx payload=json_build owner="$user" repo="$path"
|
||||
|
||||
local HTTP_METHOD=DELETE
|
||||
setx result=curlto "$url" "$payload" "" \
|
||||
-H 'Content-Type: application/json' \
|
||||
|
@ -289,9 +299,9 @@ function gogs_delete_action() {
|
|||
url: $url
|
||||
payload: $payload
|
||||
result: $result"
|
||||
if [ -n "$result" ]; then
|
||||
echo "$result"
|
||||
fi
|
||||
isatty && estep "Suppression du dépôt $repourl"
|
||||
[ -n "$result" ] && echo "$result"
|
||||
return 0
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
|
Loading…
Reference in New Issue