This commit is contained in:
lda committed 2026-08-23 18:52:19 +07:00 Verified
1 parent e70a012b03
commit 067eff1ec8
3 files changed
+47 -7

No files matched your search

+28 -2
View File
@@ -47,6 +47,23 @@ prepare_directory() {
printf '%s\n' "$directory"
}
default_manifest_path() {
local css_destination="$1"
local templates_destination="$2"
local state_directory manifest_key
if [[ -n "${GITEA_GITHUB_THEME_STATE_DIR:-}" ]]; then
state_directory="$GITEA_GITHUB_THEME_STATE_DIR"
elif [[ $EUID -eq 0 ]]; then
state_directory="/var/lib/gitea-github-theme"
else
state_directory="${XDG_STATE_HOME:-${HOME:-.}/.local/state}/gitea-github-theme"
fi
manifest_key="$(printf '%s\0%s' "$css_destination" "$templates_destination" | sha256sum | awk '{print $1}')"
printf '%s/%s.manifest\n' "$state_directory" "$manifest_key"
}
remove_theme_files() {
local css_destination="$1"
local templates_destination="$2"
@@ -98,11 +115,20 @@ main() {
local version css_destination templates_destination manifest release_path
require_command find
require_command sha256sum
require_command awk
if [[ "${1:-}" == "--print-manifest-path" ]]; then
css_destination="$(prepare_directory "${2:-}")"
templates_destination="$(prepare_directory "${3:-}")"
default_manifest_path "$css_destination" "$templates_destination"
return
fi
if [[ "${1:-}" == "--remove" ]]; then
css_destination="$(prepare_directory "${2:-}")"
templates_destination="$(prepare_directory "${3:-}")"
manifest="${4:-$templates_destination/.gitea-github-theme-files}"
manifest="${4:-$(default_manifest_path "$css_destination" "$templates_destination")}"
remove_theme_files "$css_destination" "$templates_destination" "$manifest"
printf 'Removed installed Gitea GitHub theme files.\n'
return
@@ -130,7 +156,7 @@ main() {
read -r -p "Templates destination (for example /path/to/gitea/templates): " templates_destination
fi
templates_destination="$(prepare_directory "$templates_destination")"
manifest="${4:-$templates_destination/.gitea-github-theme-files}"
manifest="${4:-$(default_manifest_path "$css_destination" "$templates_destination")}"
if [[ "$version" == "latest" ]]; then
release_path="latest/download"