@@ -5,12 +5,19 @@ namespace GitContentSearch
55 public class GitHelper : IGitHelper
66 {
77 private readonly IProcessWrapper _processWrapper ;
8+ private readonly string ? _workingDirectory ;
89
910 public GitHelper ( IProcessWrapper processWrapper )
1011 {
1112 _processWrapper = processWrapper ;
1213 }
1314
15+ public GitHelper ( IProcessWrapper processWrapper , string ? workingDirectory )
16+ {
17+ _processWrapper = processWrapper ;
18+ _workingDirectory = workingDirectory ;
19+ }
20+
1421 public string GetCommitTime ( string commitHash )
1522 {
1623 var startInfo = new ProcessStartInfo
@@ -20,7 +27,8 @@ public string GetCommitTime(string commitHash)
2027 RedirectStandardOutput = true ,
2128 RedirectStandardError = true ,
2229 UseShellExecute = false ,
23- CreateNoWindow = true
30+ CreateNoWindow = true ,
31+ WorkingDirectory = _workingDirectory // Set the working directory
2432 } ;
2533
2634 var result = _processWrapper . Start ( startInfo ) ;
@@ -50,7 +58,8 @@ public void RunGitShow(string commit, string filePath, string outputFile)
5058 RedirectStandardOutput = true ,
5159 RedirectStandardError = true ,
5260 UseShellExecute = false ,
53- CreateNoWindow = true
61+ CreateNoWindow = true ,
62+ WorkingDirectory = _workingDirectory // Set the working directory
5463 } ;
5564
5665 ProcessResult result ;
@@ -74,7 +83,8 @@ public string[] GetGitCommits(string earliest, string latest)
7483 RedirectStandardOutput = true ,
7584 RedirectStandardError = true ,
7685 UseShellExecute = false ,
77- CreateNoWindow = true
86+ CreateNoWindow = true ,
87+ WorkingDirectory = _workingDirectory // Set the working directory
7888 } ;
7989
8090 var result = _processWrapper . Start ( startInfo ) ;
0 commit comments