Skip to content

Commit 5517743

Browse files
committed
forge--set-topic-labels: Properly encode old label IDs
I really messed up ID handling in the early days. Fixing that will force all user has to recreate their local database from scratch, which is why I still haven't done it. Anyway, this is becoming more of a problem now that we are switching to using GraphQL even for mutations. While the REST API usually takes numbers and names to identify objects, the GraphQL API expects IDs. `base64-decode-string' on our label IDsgives us a string using one of the following two forms. (These are the "support" and "area: github" labels of this repository.) (base64-decode-string "Z2l0aHViLmNvbTowMTA6UmVwb3NpdG9yeTE0MTM3ODE5NDowNTpMYWJlbDExODMxMDE5ODg=") => "github.com:010:Repository141378194:05:Label1183101988" (base64-decode-string "Z2l0aHViLmNvbTowMTA6UmVwb3NpdG9yeTE0MTM3ODE5NDpMQV9rd0RPQ0cxQ2tzOEFBQUFCY0hhQzdR") => "github.com:010:Repository141378194:LA_kwDOCG1Cks8AAAABcHaC7Q" In the latter case we can use "LA_kwDOCG1Cks8AAAABcHaC7Q" as-is, in the former case we have to encode "05:Label1183101988" to get the ID used on Github, "MDU6TGFiZWwxMTgzMTAxOTg4". (base64-encode-string "05:Label1183101988") => "MDU6TGFiZWwxMTgzMTAxOTg4" It seemed like a good idea, in the "we might as well" category, to try to decode the upstream ID and, if that succeeded, combine that (else the original ID as-is) with our package prefix, before encoding the combination, to avoid "double-encoding". This broke down once Github changed the format of their IDs and we now have to deal with both their new and legacy formats. Closes #784.
1 parent 540c026 commit 5517743

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# -*- mode: org -*-
2+
* v0.5.3 UNRELEASED
3+
4+
- Fixed a regression in v0.5.1, which prevented labeling topics
5+
with labels that were created before Github changed the format
6+
of label IDs. #784
7+
28
* v0.5.2 2025-06-03
39

410
- Fixed a regression in v0.5.1, which prevented the creation of a

lisp/forge-github.el

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,15 @@
955955
(cl-defmethod forge--set-topic-labels
956956
((repo forge-github-repository) topic labels)
957957
(let* ((topic-id (oref topic their-id))
958-
(old (mapcar (##forge--their-id (car %)) (oref topic labels)))
959-
(new (mapcar (##forge--their-id (car %))
958+
(their-id ; I really messed up IDs! :(
959+
(pcase-lambda (`(,id))
960+
(let* ((parts (split-string (base64-decode-string id) ":"))
961+
(maybe-id (car (last parts))))
962+
(if (string-prefix-p "Label" maybe-id)
963+
(base64-encode-string (string-join (last parts 2) ":"))
964+
maybe-id))))
965+
(old (mapcar their-id (oref topic labels)))
966+
(new (mapcar their-id
960967
(forge-sql [:select [id] :from label
961968
:where (and (= repository $s1)
962969
(in name $v2))]

0 commit comments

Comments
 (0)