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