GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(updater): keep local monitor presets on stable releases · henrik092/t3code@ad7d8ba

This repository was archived by the owner on Nov 2, 2026. It is now read-only.

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • scripts
    • update-local-fork.sh
    • update-local-fork.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎scripts/update-local-fork.sh‎

Copy file name to clipboardExpand all lines: scripts/update-local-fork.sh
+119-1Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ CHECK_COMMAND=${T3CODE_UPDATE_CHECK_COMMAND:-corepack pnpm exec vp check}
1111
TYPECHECK_COMMAND=${T3CODE_UPDATE_TYPECHECK_COMMAND:-corepack pnpm exec vp run typecheck}
1212
TEST_COMMAND=${T3CODE_UPDATE_TEST_COMMAND:-corepack pnpm exec vp test --maxWorkers=4}
1313
BUILD_COMMAND=${T3CODE_UPDATE_BUILD_COMMAND:-corepack pnpm exec vp run dist:desktop:linux}
14+
VERSION_COMMAND=${T3CODE_UPDATE_VERSION_COMMAND:-node scripts/update-release-package-versions.ts}
15+
STABLE_PATCH_COMMIT=${T3CODE_STABLE_PATCH_COMMIT:-a03a0a0a5}
1416

1517
die() {
1618
printf 'Fehler: %s\n' "$*" >&2
@@ -161,6 +163,121 @@ stage_update() {
161163
printf 'Aktivieren mit: %s activate\n' "$0"
162164
}
163165

166+
latest_stable_tag() {
167+
git tag --merged upstream/main --list \
168+
| awk '/^v[0-9]+\.[0-9]+\.[0-9]+$/' \
169+
| sort -V \
170+
| tail -n 1
171+
}
172+
173+
stage_stable_update() {
174+
cd -- "$REPO_DIR"
175+
[[ $(git branch --show-current) == main ]] || die "'stable-stage' muss auf der lokalen main laufen."
176+
[[ -z $(git status --porcelain=v1) ]] || die "Der Git-Arbeitsbaum ist nicht sauber."
177+
verify_remotes
178+
mkdir -p -- "$INSTALL_DIR"
179+
180+
git fetch --prune origin
181+
git fetch --prune --tags upstream
182+
183+
local stable_tag stable_version patch_commit stored_tag stored_patch stored_candidate
184+
stable_tag=$(latest_stable_tag)
185+
[[ -n "$stable_tag" ]] || die "Kein Stable-Release-Tag gefunden."
186+
stable_version=${stable_tag#v}
187+
patch_commit=$(git rev-parse --verify "$STABLE_PATCH_COMMIT^{commit}" 2>/dev/null) || \
188+
die "Stable-Patch-Commit nicht gefunden: $STABLE_PATCH_COMMIT"
189+
190+
stored_tag=$(read_status_value release_tag 2>/dev/null || true)
191+
stored_patch=$(read_status_value patch_commit 2>/dev/null || true)
192+
stored_candidate=$(read_status_value candidate 2>/dev/null || true)
193+
if [[ "$stored_tag" == "$stable_tag" && "$stored_patch" == "$patch_commit" && -f "$stored_candidate" ]]; then
194+
local stored_checksum actual_checksum
195+
stored_checksum=$(read_status_value sha256 2>/dev/null || true)
196+
actual_checksum=$(sha256sum -- "$stored_candidate" 2>/dev/null | cut -d' ' -f1 || true)
197+
if [[ -n "$stored_checksum" && "$stored_checksum" == "$actual_checksum" ]]; then
198+
printf 'Stable bereits aktuell: %s mit Patch %s\n' "$stable_tag" "$patch_commit"
199+
return 0
200+
fi
201+
fi
202+
203+
local worktree_dir output_dir worktree_active=0 staged_temp=""
204+
worktree_dir=$(mktemp -d "${TMPDIR:-/tmp}/t3code-stable-source.XXXXXX")
205+
output_dir=$(mktemp -d "${TMPDIR:-/tmp}/t3code-stable-build.XXXXXX")
206+
207+
cleanup_stable_stage() {
208+
local exit_code=$?
209+
trap - EXIT INT TERM
210+
if [[ $worktree_active -eq 1 ]]; then
211+
git -C "$REPO_DIR" worktree remove --force "$worktree_dir" >/dev/null 2>&1 || true
212+
fi
213+
if [[ -n "$staged_temp" ]]; then
214+
rm -f -- "$staged_temp"
215+
fi
216+
rm -rf -- "$worktree_dir" "$output_dir"
217+
exit "$exit_code"
218+
}
219+
trap cleanup_stable_stage EXIT INT TERM
220+
221+
git worktree add --detach "$worktree_dir" "$stable_tag"
222+
worktree_active=1
223+
git -C "$worktree_dir" cherry-pick "$patch_commit"
224+
225+
if [[ -n "$VERSION_COMMAND" ]]; then
226+
(cd -- "$worktree_dir" && bash -lc "$VERSION_COMMAND '$stable_version'")
227+
if [[ -n $(git -C "$worktree_dir" status --porcelain=v1) ]]; then
228+
git -C "$worktree_dir" add --all
229+
git -C "$worktree_dir" commit -m "build: align local stable package versions"
230+
fi
231+
fi
232+
233+
(cd -- "$worktree_dir" && corepack pnpm install --frozen-lockfile)
234+
(cd -- "$worktree_dir" && bash -lc "$CHECK_COMMAND")
235+
(cd -- "$worktree_dir" && bash -lc "$TYPECHECK_COMMAND")
236+
(cd -- "$worktree_dir" && bash -lc "$TEST_COMMAND")
237+
(cd -- "$worktree_dir" && env -u GITHUB_REPOSITORY -u T3CODE_DESKTOP_UPDATE_REPOSITORY \
238+
T3CODE_DESKTOP_OUTPUT_DIR="$output_dir" bash -lc "$BUILD_COMMAND")
239+
240+
local artifact_count artifact build_commit destination checksum
241+
artifact_count=$(find "$output_dir" -maxdepth 1 -type f -name '*.AppImage' -printf '.' | wc -c)
242+
[[ "$artifact_count" -eq 1 ]] || die "Erwartete genau ein AppImage, gefunden: $artifact_count"
243+
artifact=$(find "$output_dir" -maxdepth 1 -type f -name '*.AppImage' -print -quit)
244+
build_commit=$(git -C "$worktree_dir" rev-parse HEAD)
245+
destination="$INSTALL_DIR/T3-Code-stable-local-$stable_version-$(printf '%.12s' "$patch_commit")-x86_64.AppImage"
246+
staged_temp="$destination.next.$$"
247+
install -m 0755 -- "$artifact" "$staged_temp"
248+
checksum=$(sha256sum -- "$staged_temp" | cut -d' ' -f1)
249+
if [[ -e "$destination" ]]; then
250+
local existing_checksum
251+
existing_checksum=$(sha256sum -- "$destination" 2>/dev/null | cut -d' ' -f1) || \
252+
die "Bestehender Build ist nicht lesbar: $destination"
253+
[[ "$existing_checksum" == "$checksum" ]] || \
254+
die "Build-Ziel existiert mit abweichendem Inhalt: $destination"
255+
rm -f -- "$staged_temp"
256+
else
257+
mv -T -- "$staged_temp" "$destination"
258+
fi
259+
staged_temp=""
260+
261+
local temporary_status="$STATUS_PATH.next.$$"
262+
{
263+
printf 'candidate\t%s\n' "$destination"
264+
printf 'sha256\t%s\n' "$checksum"
265+
printf 'commit\t%s\n' "$build_commit"
266+
printf 'release_tag\t%s\n' "$stable_tag"
267+
printf 'patch_commit\t%s\n' "$patch_commit"
268+
} > "$temporary_status"
269+
mv -f -- "$temporary_status" "$STATUS_PATH"
270+
271+
git -C "$REPO_DIR" worktree remove --force "$worktree_dir"
272+
worktree_active=0
273+
trap - EXIT INT TERM
274+
rm -rf -- "$worktree_dir" "$output_dir"
275+
276+
printf 'Geprüfter Stable-Build bereit: %s\n' "$destination"
277+
printf 'Launcher unverändert: %s\n' "$LAUNCHER_PATH"
278+
printf 'Aktivieren mit: %s activate\n' "$0"
279+
}
280+
164281
activate_update() {
165282
local candidate expected actual current
166283
candidate=$(read_status_value candidate) || die "Kein bereitgestellter Build in $STATUS_PATH"
@@ -176,6 +293,7 @@ activate_update() {
176293

177294
case ${1:-} in
178295
stage) stage_update ;;
296+
stable-stage) stage_stable_update ;;
179297
activate) activate_update ;;
180-
*) die "Aufruf: $0 {stage|activate}" ;;
298+
*) die "Aufruf: $0 {stage|stable-stage|activate}" ;;
181299
esac
Collapse file

‎scripts/update-local-fork.test.ts‎

Copy file name to clipboardExpand all lines: scripts/update-local-fork.test.ts
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ function makeFixture(options?: { readonly conflict?: boolean }) {
7878
writeCommit(upstreamWork, "upstream.txt", "new upstream\n", "upstream change");
7979
}
8080
git(upstreamWork, "push", "origin", "main");
81+
git(upstreamWork, "tag", "v0.0.1");
82+
git(upstreamWork, "push", "origin", "v0.0.1");
83+
84+
writeCommit(work, "local-patch.txt", "monitor presets\n", "local stable patch");
85+
const stablePatchCommit = git(work, "rev-parse", "HEAD");
8186

8287
const oldBuild = NodePath.join(install, "old.AppImage");
8388
NodeFS.writeFileSync(oldBuild, "old");
@@ -95,6 +100,8 @@ function makeFixture(options?: { readonly conflict?: boolean }) {
95100
T3CODE_UPDATE_TYPECHECK_COMMAND: "true",
96101
T3CODE_UPDATE_TEST_COMMAND: "true",
97102
T3CODE_UPDATE_BUILD_COMMAND: 'touch "$T3CODE_DESKTOP_OUTPUT_DIR/T3-Code-test-x86_64.AppImage"',
103+
T3CODE_UPDATE_VERSION_COMMAND: "true",
104+
T3CODE_STABLE_PATCH_COMMIT: stablePatchCommit,
98105
};
99106
return { work, install, launcher, oldBuild, env };
100107
}
@@ -155,6 +162,41 @@ describe("local T3 Code fork updater", () => {
155162
expect(NodeFS.realpathSync(fixture.launcher)).toBe(candidate);
156163
});
157164

165+
it("builds the latest stable tag with the configured local patch", () => {
166+
const fixture = makeFixture();
167+
const before = git(fixture.work, "rev-parse", "main");
168+
169+
const stage = runUpdate(fixture, "stable-stage");
170+
171+
expect(stage.status, stage.stderr).toBe(0);
172+
expect(stage.stdout).toContain("Geprüfter Stable-Build bereit");
173+
expect(git(fixture.work, "rev-parse", "main")).toBe(before);
174+
expect(NodeFS.realpathSync(fixture.launcher)).toBe(fixture.oldBuild);
175+
176+
const status = NodeFS.readFileSync(
177+
NodePath.join(fixture.install, ".t3code-local-update-status"),
178+
"utf8",
179+
);
180+
expect(status).toContain("release_tag\tv0.0.1");
181+
expect(status).toContain(`patch_commit\t${fixture.env.T3CODE_STABLE_PATCH_COMMIT}`);
182+
expect(runUpdate(fixture, "activate").status).toBe(0);
183+
expect(NodeFS.realpathSync(fixture.launcher)).toContain("T3-Code-stable-local-0.0.1-");
184+
});
185+
186+
it("skips rebuilding an unchanged stable release and patch", () => {
187+
const fixture = makeFixture();
188+
expect(runUpdate(fixture, "stable-stage").status).toBe(0);
189+
190+
const restage = runUpdate(fixture, "stable-stage", {
191+
...fixture.env,
192+
T3CODE_UPDATE_BUILD_COMMAND:
193+
'printf changed > "$T3CODE_DESKTOP_OUTPUT_DIR/T3-Code-test-x86_64.AppImage"',
194+
});
195+
196+
expect(restage.status, restage.stderr).toBe(0);
197+
expect(restage.stdout).toContain("Stable bereits aktuell");
198+
});
199+
158200
it("does not rebuild or touch the active build when the merged head is unchanged", () => {
159201
const fixture = makeFixture();
160202
expect(runUpdate(fixture, "stage").status).toBe(0);

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.