From 59b9d7d22276c316e002b6c780dc8cb276888f86 Mon Sep 17 00:00:00 2001 From: Samuel Onoja Date: Mon, 3 Aug 2026 11:16:31 +0100 Subject: [PATCH] add deleted branch model --- pkg/commands/models/branch.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pkg/commands/models/branch.go b/pkg/commands/models/branch.go index 4dc48a88d..e02d85389 100644 --- a/pkg/commands/models/branch.go +++ b/pkg/commands/models/branch.go @@ -5,6 +5,39 @@ import ( "sync/atomic" ) +// DeletedBranch is a branch that was detected as no longer existing locally but +// whose commit history can still be recovered (e.g. from the reflog). +type DeletedBranch struct { + Name string + DisplayName string + // the commit hash the branch pointed at when it was last seen + CommitHash string + // indicator of when the branch was last checked out e.g. '2d', '3m' + Recency string + // unix timestamp of when the branch was last committed to; used for sorting + UnixTimestamp int64 +} + +func (b *DeletedBranch) FullRefName() string { + return "refs/heads/" + b.Name +} + +func (b *DeletedBranch) ID() string { + return b.RefName() +} + +func (b *DeletedBranch) RefName() string { + return b.Name +} + +func (b *DeletedBranch) URN() string { + return "deleted-branch-" + b.ID() +} + +func (b *DeletedBranch) Description() string { + return b.DisplayName +} + // Branch : A git branch // duplicating this for now type Branch struct {