Compare commits
No commits in common. "038424b52630be62f749e1cfaa4d7741d0cb7c4d" and "f06d537ffb9ce1554db4d73713c506ebf800211f" have entirely different histories.
038424b526
...
f06d537ffb
77
rtenets
77
rtenets
|
@ -117,17 +117,9 @@ gitea() {
|
||||||
|
|
||||||
local method="$1"
|
local method="$1"
|
||||||
local request="$2"
|
local request="$2"
|
||||||
local data=""
|
\curl -X "${request}" \
|
||||||
|
|
||||||
if [[ $# > 2 ]]; then
|
|
||||||
data="$3"
|
|
||||||
fi
|
|
||||||
|
|
||||||
\curl -s -X "${request}" \
|
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" "${ENDPOINT}/${method}"
|
||||||
-d "${data}" \
|
|
||||||
"${ENDPOINT}/${method}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------- Git commands -----------------------
|
# ----------------- Git commands -----------------------
|
||||||
|
@ -263,71 +255,6 @@ create_tenet_file_tree() {
|
||||||
script_stub make_all_figures "Generating figures..."
|
script_stub make_all_figures "Generating figures..."
|
||||||
}
|
}
|
||||||
|
|
||||||
get_gitea_owner() {
|
|
||||||
gitea /user GET | jq -r '.login'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if repository exists
|
|
||||||
get_gitea_repo() {
|
|
||||||
local owner="$1"
|
|
||||||
local repo_name="$2"
|
|
||||||
gitea "/repos/${owner}/${repo_name}" GET
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create a repository on gitea
|
|
||||||
create_gitea_repo() {
|
|
||||||
local owner="$1"
|
|
||||||
local repo_name="$2"
|
|
||||||
local get_response="$(get_gitea_repo "${owner}" "${repo_name}")"
|
|
||||||
|
|
||||||
# Check if repo already exits
|
|
||||||
if [[ "$(jq '.id' <<< "${get_response}")" == "null" ]]; then
|
|
||||||
info "creating repository '${repo_name}' on gitea"
|
|
||||||
gitea /user/repos POST "{ \"name\": \"${repo_name}\", \"private\": true }"
|
|
||||||
else
|
|
||||||
info "found repository '${repo_name}' on gitea"
|
|
||||||
printf "%s" "${get_response}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# API call to setup the software heritage webhook
|
|
||||||
setup_software_heritage_hook() {
|
|
||||||
local owner="$1"
|
|
||||||
local repo_name="$2"
|
|
||||||
local remote_url="$3"
|
|
||||||
#gitea "/repos/${owner}/${repo_name}/hooks" GET
|
|
||||||
gitea "/repos/${owner}/${repo_name}/hooks" POST \
|
|
||||||
"{ \"type\": \"gitea\",
|
|
||||||
\"config\": {
|
|
||||||
\"content_type\": \"json\",
|
|
||||||
\"url\": \"https://archive.softwareheritage.org/api/1/origin/save/git/url/${remote_url}\"
|
|
||||||
},
|
|
||||||
\"events\": [\"release\"],
|
|
||||||
\"active\": true
|
|
||||||
}"
|
|
||||||
info "created Software Hertiage webhook for releases in gitea"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Setup remote
|
|
||||||
setup_dalembert_gitea() {
|
|
||||||
local repo_name="$(basename <<< "${PWD}")"
|
|
||||||
local owner="$(get_gitea_owner)"
|
|
||||||
local repo_json="$(create_gitea_repo "${repo_name}")"
|
|
||||||
local remote_ssh="$(jq '.ssh_url' <<< "${repo_json}")"
|
|
||||||
local remote_http="$(jq '.clone_url' <<< "${repo_json}")"
|
|
||||||
|
|
||||||
if [[ "$(\git remote | \grep -c '^dalembert$')" == "0" ]]; then
|
|
||||||
\git remote add dalembert "${remote_ssh}"
|
|
||||||
info "created remote dalembert with '${remote_ssh}"
|
|
||||||
else
|
|
||||||
\git remote set-url dalembert "${remote_ssh}"
|
|
||||||
info "set remote dalembert with '${remote_ssh}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
setup_software_heritage_hook "${owner}" "${repo_name}" "${remote_http}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Create git repository
|
# Create git repository
|
||||||
create_repo() {
|
create_repo() {
|
||||||
local repo_name="$1"
|
local repo_name="$1"
|
||||||
|
|
Loading…
Reference in New Issue