Compare commits

...
2 Commits
Author SHA1 Message Date
Christoph Brandau a6c86daf62 feat(gitea): upload release assets to Gitea
publish / Build and publish Windows installer (release) Successful in 28m43s
publish / Build and publish Ubuntu AppImage (release) Successful in 22m26s
publish / Build and publish gitty-desktop to AUR (release) Successful in 45m32s
This update introduces functionality to upload release assets to Gitea. A new helper function has been added to handle the API requests and manage the upload process, ensuring that existing assets are not duplicated. The main function has been modified to call this new upload feature after resolving the version.

- Implemented asset upload to Gitea releases
- Added checks to prevent duplicate uploads
- Enhanced error handling for missing configuration variables
2026-08-10 14:07:08 +02:00
Christoph Brandau f88b6961d1 fix(history): preserve branch colors across parent lanes
Keep branch metadata attached to each parent lane so the history graph
can render consistent colors and markers after merges and branch
transitions. Also soften the styling for behind-path segments to better
match the updated dot coloring.
2026-08-10 10:48:31 +02:00
3 changed files with 74 additions and 7 deletions
+65
View File
@@ -1,11 +1,15 @@
import argparse
import io
import json
import mimetypes
import os
import uuid
from datetime import datetime, timezone
from pathlib import Path
from typing import Any, Iterable, List, NamedTuple, Optional
from urllib.parse import urlparse
from urllib.parse import quote, urlencode
from urllib.request import Request, urlopen
from minio import Minio
from minio.error import S3Error
@@ -329,6 +333,65 @@ def _publish_target(
)
def _gitea_request(url: str, token: str, data: Optional[bytes] = None, **headers: str):
request = Request(url, data=data, headers={"Authorization": f"token {token}", **headers})
return urlopen(request, timeout=120)
def _upload_gitea_release_asset(version: str, artifact: Path) -> None:
"""Attach the installer to the Gitea release that triggered this build."""
api_url = os.environ.get("GITEA_API", "").rstrip("/")
owner = os.environ.get("OWNER", "")
repo = os.environ.get("REPO", "")
token = os.environ.get("GITEA_TOKEN") or os.environ.get("GITEA_FALLBACK_TOKEN")
if not all((api_url, owner, repo, token)):
raise ConfigurationError(
"GITEA_API, OWNER, REPO and GITEA_TOKEN are required to publish "
"the release asset."
)
release_url = (
f"{api_url}/repos/{quote(owner, safe='')}/{quote(repo, safe='')}"
f"/releases/tags/{quote(version, safe='')}"
)
with _gitea_request(release_url, token) as response:
release = json.load(response)
existing_names = {
asset.get("name") for asset in release.get("assets", []) if isinstance(asset, dict)
}
if artifact.name in existing_names:
print(f"Release asset {artifact.name} already exists; skipping upload.")
return
boundary = f"----gitty-{uuid.uuid4().hex}"
content_type = mimetypes.guess_type(artifact.name)[0] or "application/octet-stream"
body = b"".join(
(
f"--{boundary}\r\n".encode(),
(
f'Content-Disposition: form-data; name="attachment"; '
f'filename="{artifact.name}"\r\n'
).encode(),
f"Content-Type: {content_type}\r\n\r\n".encode(),
artifact.read_bytes(),
f"\r\n--{boundary}--\r\n".encode(),
)
)
upload_url = (
f"{api_url}/repos/{quote(owner, safe='')}/{quote(repo, safe='')}"
f"/releases/{release['id']}/assets?{urlencode({'name': artifact.name})}"
)
with _gitea_request(
upload_url,
token,
data=body,
**{"Content-Type": f"multipart/form-data; boundary={boundary}"},
):
pass
print(f"Attached {artifact.name} to Gitea release {version}.")
def main(version: Optional[str] = None, app_dir: Optional[str] = None) -> None:
resolved_version = _resolve_version(version)
artifact_base_url = os.environ.get("ARTIFACT_BASE_URL", "")
@@ -385,6 +448,8 @@ def main(version: Optional[str] = None, app_dir: Optional[str] = None) -> None:
artifact_base_url=artifact_base_url,
)
_upload_gitea_release_asset(resolved_version, primary)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
+3 -4
View File
@@ -2689,9 +2689,8 @@
filter: drop-shadow(0 0 3px rgba(224,160,64,0.24));
}
.graph-svg path.graph-segment-behind {
stroke: #7aacff;
stroke-dasharray: 4 4;
filter: drop-shadow(0 0 3px rgba(122,172,255,0.24));
filter: drop-shadow(0 0 3px rgba(122,172,255,0.2));
}
.graph-dot {
position: absolute;
@@ -2715,8 +2714,8 @@
box-shadow: 0 0 0 1px rgba(224,160,64,0.42), 0 0 10px rgba(224,160,64,0.16);
}
.graph-dot.behind {
background: #7aacff;
box-shadow: 0 0 0 1px rgba(122,172,255,0.46), 0 0 10px rgba(122,172,255,0.18);
background: var(--dot-color, #5a8cf8);
box-shadow: 0 0 0 1px var(--dot-color, #5a8cf8), 0 0 10px rgba(122,172,255,0.18);
}
.graph-dot.tip { width: 14px; height: 14px; box-shadow: 0 0 0 1px var(--dot-color, #5a8cf8); }
.graph-dot.merge {
+6 -3
View File
@@ -140,15 +140,18 @@
const currentBranches = branchMembership.get(commit.hash) ?? localBranchRefs(commit);
const commitBranches = uniqueStrings([...(beforeBranches[col] ?? []), ...currentBranches]);
after[col] = commit.parents.length > 0 ? commit.parents[0] : null;
afterBranches[col] = after[col] ? commitBranches.slice() : [];
const firstParent = commit.parents[0] ?? null;
after[col] = firstParent;
afterBranches[col] = firstParent
? (branchMembership.get(firstParent) ?? commitBranches).slice()
: [];
const fromCommit = new Set<number>([col]);
for (let p = 1; p < commit.parents.length; p++) {
let slot = after.indexOf(null);
if (slot === -1) { slot = after.length; after.push(null); afterBranches.push([]); }
after[slot] = commit.parents[p];
afterBranches[slot] = [];
afterBranches[slot] = (branchMembership.get(commit.parents[p]) ?? commitBranches).slice();
fromCommit.add(slot);
}