@@ -199,6 +199,15 @@ public interface IGitClient
199199 /// <returns>String output of git command</returns>
200200 ITask < string > DiscardAll ( IOutputProcessor < string > processor = null ) ;
201201
202+ /// <summary>
203+ /// Executes at least one `git checkout` command to checkout files at the given changeset
204+ /// </summary>
205+ /// <param name="changeset">The md5 of the changeset</param>
206+ /// <param name="files">The files to check out</param>
207+ /// <param name="processor">A custom output processor instance</param>
208+ /// <returns>String output of git command</returns>
209+ ITask < string > CheckoutVersion ( string changeset , IEnumerable < string > files , IOutputProcessor < string > processor = null ) ;
210+
202211 /// <summary>
203212 /// Executes at least one `git reset HEAD` command to remove files from the git index.
204213 /// </summary>
@@ -241,6 +250,13 @@ public interface IGitClient
241250 /// <returns><see cref="List<T>"/> of <see cref="GitLogEntry"/> output</returns>
242251 ITask < List < GitLogEntry > > Log ( BaseOutputListProcessor < GitLogEntry > processor = null ) ;
243252
253+ /// <summary>
254+ /// Executes `git log -- <file>` to get the history of a specific file.
255+ /// </summary>
256+ /// <param name="processor">A custom output processor instance</param>
257+ /// <returns><see cref="List<T>"/> of <see cref="GitLogEntry"/> output</returns>
258+ ITask < List < GitLogEntry > > LogFile ( NPath file , BaseOutputListProcessor < GitLogEntry > processor = null ) ;
259+
244260 /// <summary>
245261 /// Executes `git --version` to get the git version.
246262 /// </summary>
@@ -332,6 +348,17 @@ public ITask<List<GitLogEntry>> Log(BaseOutputListProcessor<GitLogEntry> process
332348 . Then ( ( success , list ) => success ? list : new List < GitLogEntry > ( ) ) ;
333349 }
334350
351+ ///<inheritdoc/>
352+ public ITask < List < GitLogEntry > > LogFile ( NPath file , BaseOutputListProcessor < GitLogEntry > processor = null )
353+ {
354+ return new GitLogTask ( file , new GitObjectFactory ( environment ) , cancellationToken , processor )
355+ . Configure ( processManager )
356+ . Catch ( exception => exception is ProcessException &&
357+ exception . Message . StartsWith ( "fatal: your current branch" ) &&
358+ exception . Message . EndsWith ( "does not have any commits yet" ) )
359+ . Then ( ( success , list ) => success ? list : new List < GitLogEntry > ( ) ) ;
360+ }
361+
335362 ///<inheritdoc/>
336363 public ITask < TheVersion > Version ( IOutputProcessor < TheVersion > processor = null )
337364 {
@@ -549,6 +576,13 @@ public ITask<string> DiscardAll(IOutputProcessor<string> processor = null)
549576 . Configure ( processManager ) ;
550577 }
551578
579+ ///<inheritdoc/>
580+ public ITask < string > CheckoutVersion ( string changeset , IEnumerable < string > files , IOutputProcessor < string > processor = null )
581+ {
582+ return new GitCheckoutTask ( changeset , files , cancellationToken , processor )
583+ . Configure ( processManager ) ;
584+ }
585+
552586 ///<inheritdoc/>
553587 public ITask < string > Remove ( IList < string > files ,
554588 IOutputProcessor < string > processor = null )
0 commit comments