uh
This commit is contained in:
3 files changed
+47
-7
No files matched your search
+16
-2
@@ -27,6 +27,20 @@ if [[ -z "$custom_path" || "$custom_path" == *$'\n'* ]]; then
|
|||||||
printf 'CustomPath must be exactly one non-empty path.\n' >&2
|
printf 'CustomPath must be exactly one non-empty path.\n' >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
manifest_path="$("$SCRIPT_DIRECTORY/install-gitea-github-theme.sh" --print-manifest-path \
|
||||||
|
"$custom_path/public/assets/css" "$custom_path/templates")"
|
||||||
|
|
||||||
|
# Move manifests written by earlier script versions out of CustomPath before Gitea dump scans it.
|
||||||
|
for legacy_manifest in \
|
||||||
|
"$custom_path/.gitea-github-theme-files" \
|
||||||
|
"$custom_path/templates/.gitea-github-theme-files"; do
|
||||||
|
if [[ -f "$legacy_manifest" && ! -e "$manifest_path" ]]; then
|
||||||
|
mkdir -p "$(dirname "$manifest_path")"
|
||||||
|
mv -- "$legacy_manifest" "$manifest_path"
|
||||||
|
printf 'Moved theme manifest to %s.\n' "$manifest_path"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if [[ ! "$gitea_version" =~ ^v?([0-9]+\.[0-9]+) ]]; then
|
if [[ ! "$gitea_version" =~ ^v?([0-9]+\.[0-9]+) ]]; then
|
||||||
printf 'Unable to determine major.minor from Gitea version: %s\n' "$gitea_version" >&2
|
printf 'Unable to determine major.minor from Gitea version: %s\n' "$gitea_version" >&2
|
||||||
@@ -54,11 +68,11 @@ if [[ -z "$theme_version" ]]; then
|
|||||||
exec "$SCRIPT_DIRECTORY/install-gitea-github-theme.sh" --remove \
|
exec "$SCRIPT_DIRECTORY/install-gitea-github-theme.sh" --remove \
|
||||||
"$custom_path/public/assets/css" \
|
"$custom_path/public/assets/css" \
|
||||||
"$custom_path/templates" \
|
"$custom_path/templates" \
|
||||||
"$custom_path/.gitea-github-theme-files"
|
"$manifest_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$SCRIPT_DIRECTORY/install-gitea-github-theme.sh" \
|
exec "$SCRIPT_DIRECTORY/install-gitea-github-theme.sh" \
|
||||||
"$theme_version" \
|
"$theme_version" \
|
||||||
"$custom_path/public/assets/css" \
|
"$custom_path/public/assets/css" \
|
||||||
"$custom_path/templates" \
|
"$custom_path/templates" \
|
||||||
"$custom_path/.gitea-github-theme-files"
|
"$manifest_path"
|
||||||
@@ -47,6 +47,23 @@ prepare_directory() {
|
|||||||
printf '%s\n' "$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() {
|
remove_theme_files() {
|
||||||
local css_destination="$1"
|
local css_destination="$1"
|
||||||
local templates_destination="$2"
|
local templates_destination="$2"
|
||||||
@@ -98,11 +115,20 @@ main() {
|
|||||||
local version css_destination templates_destination manifest release_path
|
local version css_destination templates_destination manifest release_path
|
||||||
|
|
||||||
require_command find
|
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
|
if [[ "${1:-}" == "--remove" ]]; then
|
||||||
css_destination="$(prepare_directory "${2:-}")"
|
css_destination="$(prepare_directory "${2:-}")"
|
||||||
templates_destination="$(prepare_directory "${3:-}")"
|
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"
|
remove_theme_files "$css_destination" "$templates_destination" "$manifest"
|
||||||
printf 'Removed installed Gitea GitHub theme files.\n'
|
printf 'Removed installed Gitea GitHub theme files.\n'
|
||||||
return
|
return
|
||||||
@@ -130,7 +156,7 @@ main() {
|
|||||||
read -r -p "Templates destination (for example /path/to/gitea/templates): " templates_destination
|
read -r -p "Templates destination (for example /path/to/gitea/templates): " templates_destination
|
||||||
fi
|
fi
|
||||||
templates_destination="$(prepare_directory "$templates_destination")"
|
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
|
if [[ "$version" == "latest" ]]; then
|
||||||
release_path="latest/download"
|
release_path="latest/download"
|
||||||
|
|||||||
Executable → Regular
+3
-3
@@ -8,7 +8,6 @@ from pathlib import Path
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
PATTERN = re.compile(
|
PATTERN = re.compile(
|
||||||
# r"^rollout-"
|
# r"^rollout-"
|
||||||
r"(?P<date>\d{4}-\d{2}-\d{2})"
|
r"(?P<date>\d{4}-\d{2}-\d{2})"
|
||||||
@@ -49,6 +48,7 @@ def format_size(size: int) -> str:
|
|||||||
return f"{size} B"
|
return f"{size} B"
|
||||||
return f"{value:.1f} {unit}"
|
return f"{value:.1f} {unit}"
|
||||||
value /= 1024
|
value /= 1024
|
||||||
|
raise ValueError() # unreachable
|
||||||
|
|
||||||
|
|
||||||
def format_session_line(file: Path) -> str | None:
|
def format_session_line(file: Path) -> str | None:
|
||||||
@@ -62,8 +62,8 @@ def format_session_line(file: Path) -> str | None:
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
f'{parsed["started"]:%Y-%m-%d %H:%M:%S} | '
|
f'{parsed["started"]:%Y-%m-%d %H:%M:%S} | '
|
||||||
f'updated {modified:%Y-%m-%d %H:%M:%S} | '
|
f"updated {modified:%Y-%m-%d %H:%M:%S} | "
|
||||||
f'{size:>8} | '
|
f"{size:>8} | "
|
||||||
f'codex resume {parsed["uuid"]}'
|
f'codex resume {parsed["uuid"]}'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user