@@ -81,11 +81,12 @@ interface ContextMenuProps {
8181 commit : CommitInfo ;
8282 repoPath : string ;
8383 localOnlyBranches : Set < string > ;
84+ staleBranches : Set < string > ;
8485 onClose : ( ) => void ;
8586 onRefresh : ( ) => void ;
8687}
8788
88- function ContextMenu ( { x, y, commit, repoPath, localOnlyBranches, onClose, onRefresh } : ContextMenuProps ) {
89+ function ContextMenu ( { x, y, commit, repoPath, localOnlyBranches, staleBranches , onClose, onRefresh } : ContextMenuProps ) {
8990 const ref = useRef < HTMLDivElement > ( null ) ;
9091
9192 useEffect ( ( ) => {
@@ -104,6 +105,10 @@ function ContextMenu({ x, y, commit, repoPath, localOnlyBranches, onClose, onRef
104105 . filter ( r => ( r . kind === "branch" || r . kind === "head" ) && localOnlyBranches . has ( r . label ) )
105106 . map ( r => r . label ) ;
106107
108+ const staleRefsOnCommit = parseRefNames ( commit . ref_names )
109+ . filter ( r => r . kind === "remote" && staleBranches . has ( r . label ) )
110+ . map ( r => r . label ) ;
111+
107112 const items : { label : string ; action : ( ) => void ; danger ?: boolean } [ ] = [
108113 { label : "Checkout" , action : ( ) => run ( [ "checkout" , commit . hash ] ) } ,
109114 {
@@ -165,6 +170,20 @@ function ContextMenu({ x, y, commit, repoPath, localOnlyBranches, onClose, onRef
165170 } ,
166171 } ) ) ,
167172 ] : [ ] ) ,
173+ ...( staleRefsOnCommit . length > 0 ? [
174+ { label : "──" , action : ( ) => { } } ,
175+ ...staleRefsOnCommit . map ( branch => ( {
176+ label : `Delete remote tracking ref "${ branch } "` ,
177+ danger : true ,
178+ action : async ( ) => {
179+ onClose ( ) ;
180+ try {
181+ await invoke ( "run_git_simple" , { args : [ "branch" , "-dr" , branch ] , cwd : repoPath } ) ;
182+ onRefresh ( ) ;
183+ } catch ( e ) { alert ( String ( e ) ) ; }
184+ } ,
185+ } ) ) ,
186+ ] : [ ] ) ,
168187 ] ;
169188
170189 return (
@@ -529,7 +548,7 @@ export function HistoryTab({ repoPath, filePath, refreshKey, onRefresh, onFileSe
529548 ) }
530549 { contextMenu && (
531550 < ContextMenu x = { contextMenu . x } y = { contextMenu . y } commit = { contextMenu . commit }
532- repoPath = { repoPath } localOnlyBranches = { localOnlyBranches }
551+ repoPath = { repoPath } localOnlyBranches = { localOnlyBranches } staleBranches = { staleBranches }
533552 onClose = { ( ) => setContextMenu ( null ) }
534553 onRefresh = { ( ) => { setContextMenu ( null ) ; onRefresh ( ) ; } } />
535554 ) }
0 commit comments