Assign readable ticket keys from project code and sequence.
Replace UUID-looking sync labels in TUI and web with keys like TAS-1, while keeping the remote UUID for task-master matching. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package ticket
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDisplayID(t *testing.T) {
|
||||
if got := (Ticket{Key: "TAS-1", ExternalID: "uuid"}).DisplayID(); got != "TAS-1" {
|
||||
t.Fatalf("got %q", got)
|
||||
}
|
||||
if got := (Ticket{ExternalID: "YT-9"}).DisplayID(); got != "YT-9" {
|
||||
t.Fatalf("got %q", got)
|
||||
}
|
||||
if got := (Ticket{}).DisplayID(); got != "" {
|
||||
t.Fatalf("got %q", got)
|
||||
}
|
||||
}
|
||||
@@ -68,9 +68,22 @@ type Ticket struct {
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
|
||||
// Readable key assigned by the server (e.g. "ABC-42"). Optional on local-only tickets.
|
||||
Number int `json:"number,omitempty"`
|
||||
Key string `json:"key,omitempty"`
|
||||
|
||||
// External sync (optional). Local UUID stays in ID.
|
||||
Source string `json:"source,omitempty"`
|
||||
ExternalID string `json:"externalId,omitempty"`
|
||||
ExternalURL string `json:"externalUrl,omitempty"`
|
||||
SyncedAt time.Time `json:"syncedAt,omitempty"`
|
||||
}
|
||||
|
||||
// DisplayID returns the human-readable ticket label for UI.
|
||||
// Prefers the server key; falls back to ExternalID (e.g. YouTrack idReadable).
|
||||
func (t Ticket) DisplayID() string {
|
||||
if t.Key != "" {
|
||||
return t.Key
|
||||
}
|
||||
return t.ExternalID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user