@@ -62,6 +62,19 @@ public virtual bool Continue()
6262 Args = $ "{ Cmd } --continue",
6363 } . Exec ( ) ;
6464 }
65+
66+ protected string GetFriendlyNameOfCommit ( Models . Commit commit )
67+ {
68+ var branchDecorator = commit . Decorators . Find ( x => x . Type == Models . DecoratorType . LocalBranchHead || x . Type == Models . DecoratorType . RemoteBranchHead ) ;
69+ if ( branchDecorator != null )
70+ return branchDecorator . Name ;
71+
72+ var tagDecorator = commit . Decorators . Find ( x => x . Type == Models . DecoratorType . Tag ) ;
73+ if ( tagDecorator != null )
74+ return tagDecorator . Name ;
75+
76+ return commit . SHA . Substring ( 0 , 10 ) ;
77+ }
6578 }
6679
6780 public class CherryPickInProgress : InProgressContext
@@ -72,6 +85,11 @@ public Models.Commit Head
7285 private set ;
7386 }
7487
88+ public string HeadName
89+ {
90+ get => GetFriendlyNameOfCommit ( Head ) ;
91+ }
92+
7593 public CherryPickInProgress ( Repository repo ) : base ( repo . FullPath , "cherry-pick" , true )
7694 {
7795 var headSHA = File . ReadAllText ( Path . Combine ( repo . GitDir , "CHERRY_PICK_HEAD" ) ) . Trim ( ) ;
@@ -87,18 +105,32 @@ public string HeadName
87105 private set ;
88106 }
89107
108+ public string BaseName
109+ {
110+ get => GetFriendlyNameOfCommit ( Onto ) ;
111+ }
112+
90113 public Models . Commit StoppedAt
91114 {
92115 get ;
93116 private set ;
94117 }
95118
119+ public Models . Commit Onto
120+ {
121+ get ;
122+ private set ;
123+ }
124+
96125 public RebaseInProgress ( Repository repo ) : base ( repo . FullPath , "rebase" , true )
97126 {
98127 _gitDir = repo . GitDir ;
99128
100129 var stoppedSHA = File . ReadAllText ( Path . Combine ( repo . GitDir , "rebase-merge" , "stopped-sha" ) ) . Trim ( ) ;
101- StoppedAt = new Commands . QuerySingleCommit ( repo . FullPath , stoppedSHA ) . Result ( ) ;
130+ StoppedAt = new Commands . QuerySingleCommit ( repo . FullPath , stoppedSHA ) . Result ( ) ?? new Models . Commit ( ) { SHA = stoppedSHA } ;
131+
132+ var ontoSHA = File . ReadAllText ( Path . Combine ( repo . GitDir , "rebase-merge" , "onto" ) ) . Trim ( ) ;
133+ Onto = new Commands . QuerySingleCommit ( repo . FullPath , ontoSHA ) . Result ( ) ?? new Models . Commit ( ) { SHA = ontoSHA } ;
102134
103135 HeadName = File . ReadAllText ( Path . Combine ( repo . GitDir , "rebase-merge" , "head-name" ) ) . Trim ( ) ;
104136 if ( HeadName . StartsWith ( "refs/heads/" ) )
@@ -150,41 +182,23 @@ public string Current
150182 private set ;
151183 }
152184
153- public string SourceName
185+ public Models . Commit Source
154186 {
155187 get ;
156188 private set ;
157189 }
158190
159- public Models . Commit Source
191+ public string SourceName
160192 {
161- get ;
162- private set ;
193+ get => GetFriendlyNameOfCommit ( Source ) ;
163194 }
164195
165196 public MergeInProgress ( Repository repo ) : base ( repo . FullPath , "merge" , false )
166197 {
167198 Current = Commands . Branch . ShowCurrent ( repo . FullPath ) ;
168199
169200 var sourceSHA = File . ReadAllText ( Path . Combine ( repo . GitDir , "MERGE_HEAD" ) ) . Trim ( ) ;
170- Source = new Commands . QuerySingleCommit ( repo . FullPath , sourceSHA ) . Result ( ) ;
171- if ( Source == null )
172- return ;
173-
174- var branchDecorator = Source . Decorators . Find ( x => x . Type == Models . DecoratorType . LocalBranchHead || x . Type == Models . DecoratorType . RemoteBranchHead ) ;
175- if ( branchDecorator != null )
176- {
177- SourceName = branchDecorator . Name ;
178- return ;
179- }
180-
181- var tagDecorator = Source . Decorators . Find ( x => x . Type == Models . DecoratorType . Tag ) ;
182- if ( tagDecorator != null )
183- {
184- SourceName = tagDecorator . Name ;
185- }
186-
187- SourceName = Source . SHA . Substring ( 0 , 10 ) ;
201+ Source = new Commands . QuerySingleCommit ( repo . FullPath , sourceSHA ) . Result ( ) ?? new Models . Commit ( ) { SHA = sourceSHA } ;
188202 }
189203 }
190204}
0 commit comments