@@ -229,6 +229,45 @@ protected override void OnDataContextChanged(EventArgs e)
229229 }
230230 }
231231
232+ public class BranchTreeNodeDescription : TextBlock
233+ {
234+ protected override Type StyleKeyOverride => typeof ( TextBlock ) ;
235+
236+ public BranchTreeNodeDescription ( )
237+ {
238+ IsVisible = false ;
239+ }
240+
241+ protected override async void OnAttachedToVisualTree ( VisualTreeAttachmentEventArgs e )
242+ {
243+ base . OnAttachedToVisualTree ( e ) ;
244+
245+ var visible = false ;
246+
247+ do
248+ {
249+ if ( DataContext is not Models . Branch branch )
250+ break ;
251+
252+ if ( e . Root is not PopupRoot { Parent : Popup { Parent : Border owner } } )
253+ break ;
254+
255+ var tree = owner . FindAncestorOfType < BranchTree > ( ) ;
256+ if ( tree is not { DataContext : ViewModels . Repository repo } )
257+ break ;
258+
259+ var description = await new Commands . Config ( repo . FullPath ) . GetAsync ( $ "branch.{ branch . Name } .description") ;
260+ if ( string . IsNullOrEmpty ( description ) )
261+ break ;
262+
263+ Text = description ;
264+ visible = true ;
265+ } while ( false ) ;
266+
267+ SetCurrentValue ( IsVisibleProperty , visible ) ;
268+ }
269+ }
270+
232271 public partial class BranchTree : UserControl
233272 {
234273 public static readonly StyledProperty < List < ViewModels . BranchTreeNode > > NodesProperty =
@@ -805,6 +844,17 @@ private ContextMenu CreateContextMenuForLocalBranch(ViewModels.Repository repo,
805844 e . Handled = true ;
806845 } ;
807846
847+ var editDescription = new MenuItem ( ) ;
848+ editDescription . Header = App . Text ( "BranchCM.EditDescription" , branch . Name ) ;
849+ editDescription . Icon = App . CreateMenuIcon ( "Icons.Edit" ) ;
850+ editDescription . Click += async ( _ , e ) =>
851+ {
852+ var desc = await new Commands . Config ( repo . FullPath ) . GetAsync ( $ "branch.{ branch . Name } .description") ;
853+ if ( repo . CanCreatePopup ( ) )
854+ repo . ShowPopup ( new ViewModels . EditBranchDescription ( repo , branch , desc ) ) ;
855+ e . Handled = true ;
856+ } ;
857+
808858 var delete = new MenuItem ( ) ;
809859 delete . Header = App . Text ( "BranchCM.Delete" , branch . Name ) ;
810860 delete . Icon = App . CreateMenuIcon ( "Icons.Clear" ) ;
@@ -837,6 +887,7 @@ private ContextMenu CreateContextMenuForLocalBranch(ViewModels.Repository repo,
837887 } ;
838888
839889 menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
890+ menu . Items . Add ( editDescription ) ;
840891 menu . Items . Add ( rename ) ;
841892 menu . Items . Add ( delete ) ;
842893 menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
@@ -1068,6 +1119,17 @@ public ContextMenu CreateContextMenuForRemoteBranch(ViewModels.Repository repo,
10681119 }
10691120 menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
10701121
1122+ var editDescription = new MenuItem ( ) ;
1123+ editDescription . Header = App . Text ( "BranchCM.EditDescription" , branch . Name ) ;
1124+ editDescription . Icon = App . CreateMenuIcon ( "Icons.Edit" ) ;
1125+ editDescription . Click += async ( _ , e ) =>
1126+ {
1127+ var desc = await new Commands . Config ( repo . FullPath ) . GetAsync ( $ "branch.{ branch . Name } .description") ;
1128+ if ( repo . CanCreatePopup ( ) )
1129+ repo . ShowPopup ( new ViewModels . EditBranchDescription ( repo , branch , desc ) ) ;
1130+ e . Handled = true ;
1131+ } ;
1132+
10711133 var delete = new MenuItem ( ) ;
10721134 delete . Header = App . Text ( "BranchCM.Delete" , name ) ;
10731135 delete . Icon = App . CreateMenuIcon ( "Icons.Clear" ) ;
@@ -1078,6 +1140,7 @@ public ContextMenu CreateContextMenuForRemoteBranch(ViewModels.Repository repo,
10781140 e . Handled = true ;
10791141 } ;
10801142
1143+ menu . Items . Add ( editDescription ) ;
10811144 menu . Items . Add ( delete ) ;
10821145 menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
10831146
0 commit comments